Backing up documents using rsync

From Notes_Wiki
Revision as of 08:20, 22 January 2019 by Saurabh (talk | contribs)

<yambe:breadcrumb self="Backing up documents using rsync">Rsync|Rsync</yambe:breadcrumb>

Backing up documents using rsync

We can backup entire documents from one machine to another using syntax like:

rsync -vtrp --partial --delete --ignore-errors saurabh@10.5.1.222:/documents/ /documents/

Here:

  • -v is for verbose
  • -t is for copying timestamps
  • -r is for recursion
  • -p is for permissions
  • --partial is so that partial files are not deleted. Note that using --partial is better than using --inplace because of the diff algorithm and it also allows destination file to always be in consistent state.
  • --delete to delete files on destination that are not present on source. Careful
  • --ignore-errors to ignore errors occurred during copying. This may be because of root owned folders like lost+found in source dir. Use with caution


Apart from above options other useful options to consider are:

  • --progress to see progress of file being copied if you are copying big files like movies, etc.
  • -n to cause rsync to perform dry run and not do any changes. It is very useful if you want to use --delete option
  • -L to cause following of symbolic link dirs as if they are real dirs and make their copy also on destination.