Does rsync delete files on the destination that were deleted from the sending side

backuprsync

Does rsync delete files from the destination if they were deleted from the source?

For example, say in the source /home/me I have three files:

a.txt
b.txt
c.txt

Now, I run the command rsync -v /home/me/ user@ip.address:/home/backup and it copies files a.txt, b.txt and c.txt to /home/backup.

The contents of /home/backup are now

a.txt
b.txt
c.txt

If I were to delete a.txt from /home/me, would a.txt get deleted from /home/backup the next time I run rsync, is there an option I need to specify or is it just completely impossible?

If there are any alternatives to rsync that do this, they are welcome as well.

Side note: I have read this and this relating to this topic, but I couldn't exactly understand or see how it was exactly related to the question.

Best Answer

Only if you… select one of the delete options. See man rsync for more information, but here is an excerpt:

--delete                delete extraneous files from dest dirs
--delete-before         receiver deletes before xfer, not during
--delete-during         receiver deletes during the transfer
--delete-delay          find deletions during, delete after
--delete-after          receiver deletes after transfer, not during
--delete-excluded       also delete excluded files from dest dirs

There is more detailed information for these options further down the man page.