rsync allows you to synchronize two directories that can even be on different computers. All files in the target directory will be checked and, if needed, changed to have the same content as in the source directory.
Using rsync for secure remote backups
rsync can be used locally or over the network. It supports ssh, for secure remote differential backups.
rsync -e ssh -avz [src_path] email@example.com:[dst_path]
rsync -e ssh -avz /etc/ firstname.lastname@example.org:/etc/
To delete files that are on the destination system but no longer on the source system, use the --delete option:
rsync -e ssh -avz --delete /lib/ email@example.com:/lib/
Here's the full meal deal for doing a total system backup. This will completely duplicate one system onto another, over the Internet. Make sure the hardware, boot devices, etc are the same or you're in for trouble:
rsync -e ssh -avz --stats --progress --delete-after --exclude-from=/root/rsync-exclude / firstname.lastname@example.org:/
Note that "/root/rsync-exclude" should include things like:
You can use rsync to show differences between two directories without changing anything. In the following example, your /home/myuser is compared with the same folder on computer target:
rsync -e ssh -avz --delete --dry-run /home/myuser root@target:/home