Basic Rsync Backup
rsync -av source/ destination/
To/From Remote
rsync -av -e ssh source/ username@remotemachine:/path/to/destination/
Rsync cares about trailing slashes on the source argument.
For example, let a
and b
be two directories with the file foo
initially in a
:
rsync -a a b
produces b/a/foo
whereas
rsync -a a/ b
produces b/foo
. A trailing slash on the destination has no effect.
Needs rsync v.2.5.7 or later
rm -rf backup_folder.1 mv backup_folder.0 backup_folder.1 # Obviously, can have as many backups copies as you want rsync -a --delete --link-dest=../backup_folder.1 source_directory/ backup_folder.0/
If running an older rsync:
mv backup_folder.1 backup_folder.tmp mv backup_folder.0 backup_folder.1 mv backup_folder.tmp backup_folder.0 cp -al backup_folder.1/. backup_folder.0 rsync -a --delete source_directory/ backup_folder.0/