Copy directory names only (exclude files)

  • Follow


Hi,

I need to recreate some directory structures from one server to
another (Solaris 9) without copying the actual files in those
directories. Is there a way to do this without rsync?

Thanks
Mark
0
Reply mark 3/27/2008 1:58:04 PM

cd <sourcedir> ; find . -type d | cpio -pdum <targetdir>
0
Reply Harm 3/27/2008 2:02:56 PM


mark wrote:
> Hi,
> 
> I need to recreate some directory structures from one server to
> another (Solaris 9) without copying the actual files in those
> directories. Is there a way to do this without rsync?
> 
> Thanks
> Mark

mkdir

0
Reply Richard 3/27/2008 2:04:44 PM

cd <sourcedir>
find . -type d | cpio -oc | ssh <targethost> cd <targetdir> \; cpio -icdum
0
Reply Harm 3/27/2008 2:06:49 PM

mark <markg9@yahoo.com> writes:

>Hi,

>I need to recreate some directory structures from one server to
>another (Solaris 9) without copying the actual files in those
>directories. Is there a way to do this without rsync?

cd /original/dir ; find . -type d | (cd /target/dir; cpio -pdm)

Casper
-- 
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
0
Reply Casper 3/27/2008 2:07:43 PM

mark <markg9@yahoo.com> wrote:
> Hi,
> 
> I need to recreate some directory structures from one server to
> another (Solaris 9) without copying the actual files in those
> directories. Is there a way to do this without rsync?

There's an old thread about this with several alternatives:

http://groups.google.com/group/comp.unix.solaris/browse_thread/thread/e84b458b3ce4b3b8/

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
0
Reply ddunham 3/27/2008 5:35:50 PM

In article <47ebaa2f$0$14346$e4fe514c@news.xs4all.nl>,
	Casper H.S. Dik <Casper.Dik@Sun.COM> writes:
> mark <markg9@yahoo.com> writes:
> 
>>Hi,
> 
>>I need to recreate some directory structures from one server to
>>another (Solaris 9) without copying the actual files in those
>>directories. Is there a way to do this without rsync?
> 
> cd /original/dir ; find . -type d | (cd /target/dir; cpio -pdm)
> 
> Casper


To be safer, an approach involving cd should perhaps use && instead of ;

cd /original/dir && find . -type d | (cd /target/dir && cpio -pdm)

That way, if either cd fails, nothing gets copied (from or to the wrong
place).

That also extends to using it over ssh or rsh (rather than via NFS as
is implicit in the above given the "from one server to another" requirement
of the OP):

cd /original/dir && find . -type d | cpio -oca | \
   ssh remotehost "cd /target/dir && cpio -icdm)

or with tar:

cd /original/dir && tar cpf - . | \
   ssh remotehost "cd /target/dir && tar xpf -"


Using pax instead of cpio or tar is left as an exercise to the reader
(because I haven't used it often enough to know the options off the
top of my head).

Between unlike systems, cpio with -c can have portability issues, but
depending on how they differ, without -c can have problems too.  -H odc
instead may be better if both ends support it.

tar can have problems if the sending side has ACL support and the
receiving side doesn't; ;leave the p option off of the sending side in
that case.

No doubt someone will chime in with what's the most portable approach
(call that s-bait, if you know what I mean).

0
Reply Richard 3/27/2008 9:02:15 PM

6 Replies
571 Views

(page loaded in 0.092 seconds)

Similiar Articles:













7/20/2012 5:16:40 AM


Reply: