1

I want to implement a comprehensive backup script based on rsync, so I'm just experimenting now to decide the correct parameters based on my requirement. Basically, I want that any changed file should be copied from source to destination, regardless of its modification time (ie. whether or not source file is older/newer than destination file, it should be copied if the contents differ). However, it isn't working:

../src/test.txt
../dst/test.txt

Above is the folder structure. When I first ran the below command for first time, it copied the test.txt from src to dst folder.

rsync -avh --ignore-times src/ dst/

Then, I modified the contents of src/test.txt and ran above command again, and this time too it copied the updated file to dst folder.

However, I then modified the test.txt in dst folder, and ran above command, but this time, it didn't work and didn't copy the file from src/ to dst/ folder. But considering this answer, it should have worked as I've added the --ignore-times parameter.

Is this a bug with Ubuntu, or am I doing something wrong? What parameter should I add so that the file will be always copied from source to destination when the contents differ (even when the destination file is newer)?

edit

I even tried adding the --checksum parameter to copy solely based on checksums and ignoring the timestamp altogether (as the man page says). But even that didn't work.

1 Answer 1

3

For some reason, the --archive or a mode doesn't seem to work with the --ignore-times or --checksum parameters. However, the simple recursive copy mode (--recursive or r). So in my case, the following did the job perfectly:

rsync -vcr src/ dst/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .