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

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.

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.

• Just to confirm, this means that if I select --delete, rsync would delete files from the destination that were deleted from the source, making the source and destination an exact mirror? – perhapsmaybeharry Dec 18 '15 at 4:30
• Yes, but just have a read of the man page! There are caveats and hints, including running it with --dry-run. – Sparhawk Dec 18 '15 at 4:32