rsync snapshot backup using link dest option The…

rsync snapshot backup using –link-dest option.

The rsync option –link-dest is very useful for Timemachine like snapshop backup.
It compares the source with the files in the –link-dest then if the files were not changed make a hard link to them. So without using extra drive space, it can keep the snapshop copy.
When the sync source is a Samba drive, sometimes the –link-dest option does not work as expected because of the permission difference, especially the -a (archive) option is used.
The -a option is composite of -rltpgoD options.
By removing the permission (-p) check, if it’s alright, the –link-dest works properly.

rsync -rltgoDvzhH --progress -e ssh --link-dest=/home/user/dest1 source/ dest2/

Using rsync to sync files rsync avh source…

Using rsync to sync files.

rsync -avh source_folder/ target_folder/
  • -a: archive mode
  • -v: verbose
  • -h: human readable

Additional options

  • -u: update only (preserve newer files)
  • -H: preserve the hard link
  • –progress: shows progress
  • -n: dry run (without actual copying)

By the way, “/home/user/dir/” and “/home/usr/dir” are not the same thing to rsync. Without the final slash, rsync will copy the directory in its entirety. With the trailing slash, it will copy the contents of the directory but won’t recreate the directory.

For more explanations, check this nice post.