//View Tip #492
Similar Tips
» Tar remote dir over SSH
» Untar multiple files in a directory
» Bash function to decompress archives
» bzip2 ssh copy and machine power off
» Finding Newer Files [OR How To Create A Patch File]


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Why not use cp or mv to move /usr/home to /storage/export/home? Weird things happen to hard and softlinks when you mv or cp. Try it and remember that a mv between different filesystems is actually a copy and delete.

Try this instead:
# tar -C /usr -cf - home | tar -C /storage/export -xvf -

Or, to copy to a remote machine:
# tar -C /usr -cf - home | ssh user@somemachine tar -C /storage/export -xvf -

You may want to add the -z switch to the tar commands. It will add compression but it depends on the type of data and your connection speed if it really improves transfer speeds.

View Comments »


Add your comment

Comments are currently disabled
1. Why bother to use the -f flag when you are sending to stdout anyway... (example pulling files from a remote server)
  <pre>ssh user@sourceserver tar -C /media -cz share | tar -xvz</pre>
2. Do not forget the -S option to handle sparse files efficiently when needed (like transfering a virtual machine disk).
Posted 2009-01-22 16:17:38

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit