how-to_‎ > ‎

ssh and tar: copy files from a server to another over filesystem level

posted Aug 23, 2012, 1:49 AM by Daniele Albrizio   [ updated Aug 23, 2012, 3:57 AM ]
# ssh root@vserver06 tar cf - --numeric-owner -C /mnt .  | tar xf - --numeric-owner -C /mnt

Naturally you need root access via ssh and the relative password or certificate.

--numeric-owner needs to be specified or else tar uses usernames that can correspondo to different ids on different systems
-C changes directory in the proper space to get and put the files

If the source system is running, please exclude the proc, sys and dev trees.
--exclude='/sys/*' --exclude='/dev/*')