Today I had to copy a bunch of files and symlinks to a remote machine. My first attempt was to use scr directly:
$ scp -r directory host:/some/directory
But that went wrong: the symlinks were not preserved, which resulted in several files being transferred multiple times.
A simple solution could have been to create a tarball of the whole directory, copy it to the remote host and unpack it there. However, I thought... using tar on both ends through a pipe over SSH should work... so I tried... and it worked! So how is this done?
$ cd directory ; tar cvf - . | ssh sun tar xf - -C /some/directory
Yes, it's that easy! Hmm I ask myself why I didn't try this before... BTW, remember that the target directory should exist; if it doesn't, adjust the command line a bit ;-)
1 comments:
[Originally posted at 2004-10-06 11:22 am UTC]
I know what happened. pax.
But I remember I'd always forget all the switches for most of what you just mentioned and I'd just find it in the tar(1) man page.
tar cf - . | (cd todir; tar xvBpf)
I know that the switches are different now, thanks to pax, but where's my example?
Grumble.
Post a Comment