Monday, December 23, 2013

How to backup sparse file over network

Rsync will drive CPU or IO crazy. One needs to use fs specific utils to perform this kind of task. For instance, for XFS one can use xfsdump and xfsrestore via ssh tunnel
/usr/bin/ssh -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'ExitOnForwardFailure yes' -L1234:localhost:1234 test@192.168.14.189 'netcat -l -v -p 1234 | /sbin/xfsrestore - /home/bckp'
Restore Status: SUCCESS

/sbin/xfsdump -s /a/b/c -F - /home | netcat localhost 1234
Dump Status: SUCCESS
Things to note.
  1. ssh options 'UserKnownHostsFile /dev/null' and 'StrictHostKeyChecking no' omit known_hosts check, see ssh_config(5).
  2. ssh option 'ExitOnForwardFailure yes' forces ssh to exit with error if it failed to forward ports.
  3. carefully with netcat, it has 2 different cli.
  4. see xfsdump(8) and xfsrestore(8).

No comments:

Post a Comment