Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1402  / 3 Years ago, sat, august 28, 2021, 7:25:14

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)?


More From » 16.04

 Answers
0

--archive equals -rlptgoD while -t means



-t, --times
This tells rsync to transfer modification times along with the files and update them on the remote system


But you could combine that with --no-OPTION like this



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


and it should work perfectly






EDIT: actually the --ignore-timesis superfluous, this is enough



rsync -avh --no-t src/ dst/

[#9213] Saturday, August 28, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
errettas

Total Points: 160
Total Questions: 118
Total Answers: 91

Location: Laos
Member since Fri, Sep 11, 2020
4 Years ago
;