Mirror a directory exactly with rsync --delete
rsync mirror directory | make destination identical to source | delete removed files from backup too | rsync delete extraneous files | rsync | delete | mirrorWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
rsync -av --delete /var/www/vhosts/example.com/httpdocs/ /backup/example.com/httpdocs/Transfers new and changed files and, with --delete, removes everything at the destination that no longer exists in the source. The result is an exact mirror. Files deleted in the source also disappear from the backup on the next run.
Note: Swapped source and destination or a missing slash can delete entire directories in the worst case. Always check with --dry-run first what is reported as deleting.
Also searched as
- rsync mirror directory
- make destination identical to source
- delete removed files from backup too
- rsync delete extraneous files