How to remove files created at target using rsync

| | 1 min read

rsync is a powerful file and folder synchronization tool in Linux. To read more about rsync please go through this link:
http://www.zyxware.com/articles/2717/how-to-backupcopysynchronise-a-full-folder-lying-on-a-remote-server-onto-another-localremote-machine-easily-using-

rsync usually creates files or folders that are present in source to the destination folder. But there are cases where the files has been removed from source but thay are still present in destination. This can some times cause problems as the destination directory keeps on increasing in size but the source directory size is less. It usually happens when an rsync has been run by keeping a tar.gz file at the source. This will sync the tar file to the destination but even if you remove the tar file from source it will have a tar file copy at the destination. So to avoid such things and also to keep both source and destination up to date we can use rsync '--delete' option

rsync -avz --delete source destination

This will synchronize the two folders and remove the other unwanted files from destination and keep both source and destination up to date.