Random Tech Thoughts

The title above is not random

Rsync

Backup

Command:

rsync -a --delete src/ destination
  • -a archive
  • --delete delete files on destination if not present in source

About Trailing slashes

From Easy Automated Snapshot-Style Backups with Linux and Rsync

The trailing slash only has effect on the source argument.

Here’s the example, suppose we have directory a/foo/:

rsync -a a b

produces b/a/foo, whereas this command:

rsync -a a/ b

produces b/foo.

Transfer sparse file efficiently

From StackOverflow How do you synchronise huge sparse files (VM disk images) between machines?

This would be useful when transferring qemu image file. Use the --sparse option if the destination does not have that file. For example:

rsync -v --sparse --progress me@remote:~/debian6.img .

If the destination already has the sparse image, use the --inplace option:

rsync -v --inplace --progress me@remote:~/debian6.img .

From my own use, using --sparse option is faster when the destination already has the sparse file, but --inplace will avoid creating a new file.