How to Back Up Files Using Rsync

How to Back Up Files Using Rsync

with No Comments

Rsync is a utility for keeping files synced in two locations. This is a quick tutorial on how to use it to back up your files and keep them synchronized (i.e., after the initial full backup, it will write only the data that has changed since the last backup).

 

Do a test-run by invoking the following in the terminal (replace “/path/to/source” and “/path/to/destination” with the paths you need):

rsync -av --delete --progress --dry-run /path/to/source /path/to/destination

The console will then return the results of the command without actually doing anything. If it behaved as you expected, then run the command without the “--dry-run” flag, like this (once again, replace “/path/to/source” and “/path/to/destination” according to your needs):

rsync -av --delete --progress /path/to/source /path/to/destination

The command above can be incorporated into a shell script in order to create a one-click backup solution. See this post for details.

Here are a couple of things to note:

  • If you do not put a trailing slash on the source directory path (as in the examples above), it will copy the source directory and its contents into the destination directory.
  • If you put a trailing slash on the source directory path, it will copy just the contents of the source directory into the destination directory (i.e., without the top-level directory).
  • A trailing slash on the destination directory path has no effect.

Leave a Reply