Backup old files before overwriting in rsync

By default, rsync overrides old files in the destination server/folder. To resolve this use the –backup flag in rsync.

rsync -a –backup –backup-dir=”/src-old-files” /usr/src/ root@

The above rsync command will copy files from local server /usr/src to root@ If some files are overwritten in root@, these will be backed up in root@ first before they are being overwritten.

Leave a Reply