SysAdmin‎ > ‎


How to use rsync

For more info you can look at the sites I used or Google rsync

The basic use of rsync is copying a source to a destination

Basic command is

rsync -av source destination

Replace source with a path to what you want to copy(a file or folder) and replace destination with a path to where you want it to be copied to

Both source and destination can be local or via network

-a option keeps the date, time, permissions, etc of the file the same when it is copied over

-v option increases verbosity or the amount of feedback you get while it runs

An example of local rsync is

rsync -av /home/user/Desktop/someFile /home/user/Desktop/someFolder

An example of network rsync is

rsync -av /home/user/Desktop/someFile someIp:/home/user/Desktop

When the source is a folder, there is a difference between




Without the slash in someFolder, it will copy the folder itself along with the content of the folder

With the slash in someFolder, it will copy only the content of the folder and not the folder itself

Another useful option is


this deletes files that don't exist in the source folder but still exist in the destination folder

You have to be careful of this command as it will delete files

You can just append the option after -av like this

rsync -av --delete source destination

A good use of rsync is to do incremental backups

Files deleted or modified can be stored in another folder using incremental backups

The command for incremental backups is

rsync -av --backup --backup-dir=”directory” source destination

The directory is where you want to back up modified and deleted files into

For example

rsync -av --delete --backup --backup-dir=”/home/user/Desktop/backupFolder” /home/user/Desktop/someFile /home/user/Desktop/someFolder

A method of using incremental backups is to make the backup folder named by the date by naming directory “backup_$(date + '%Y-%m-%d')”, Y stands for year, m stands for month, d stands for day

You can also add in hour, minute, and second using %H, %M, and %S

An example of this would be

rsync -av --delete --backup --backup-dir=”/home/user/Desktop/backup_$(date + '%Y-%m-%d')” source destination