Force rsync to overwrite files at destination even if they’re newer

backupcommand linersync

I have an rsync backup script I run, which also restores files back where they came from when I ask. But if the files at the destination are newer than those in the backup when I try to restore, it will not replace them. I really want to replace the newer files with those in the backup but I don't see a way to make rsync do this.

tldr: is there a way to force rsync to overwrite files at the destination?

edit: I've been running rsync -avhp When I want to restore a backup, I use the same command with the "to" and "from" swapped. So it tries to copy files from the backup drive to the place on my computer they belong.

Best Answer

The manual says:

-I, --ignore-times   don't skip files that match size and time

With more details:

-I, --ignore-times

Normally rsync will skip any files that are already the same size and have the same modification timestamp. This option turns off this "quick check" behavior, causing all files to be updated.

Related Question