Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict Rsync update timestamp

Tags:

rsync

rsync -av --size-only --include="*/" --include="*.jpeg" --exclude="*" ~/alg/temperature/ ~/alg/tmp/

I use command as above to sync some files, and I don't want to update anything even timestamp if file size is the same

the option --size-only could only sync the file which changed in size

but those which no change in size will be "touched" and update the timestamp, this is what I don't want

how could I make it?

like image 379
wenchiching Avatar asked Jul 28 '13 14:07

wenchiching


People also ask

Does rsync look at timestamps?

rsync detects files modification by comparing size and mtime. However, if for any reason, the mtime is unchanged, rsync won't detect the change, although it's possible to spot it by looking at the ctime.

Will rsync overwrite newer files?

Any that have been updated will be copied over, although note that rsync is extremely efficient in that only the changed parts of files are copied and if the file is exactly the same if it is not copied over at all.

Does rsync only copy changed files?

By default, rsync will only copy new or changed files from a source to a destination. The –update or -u option is used by rsync to skip files that are still new in the destination directory. Also, –dry-run or -n enables us to execute a test operation without making any changes.

Is rsync recursive?

To sync the contents of dir1 to dir2 on the same system, you will run rsync and use the -r flag, which stands for “recursive” and is necessary for directory syncing: rsync -r dir1/ dir2.


Video Answer


1 Answers

The -a option is equivalent to -rlptgoD. You need to remove the -t. -t tells rsync to transfer modification times along with the files and update them on the remote system. You may want to try the -c skip based on checksum, not mod-time & size. This is slower, but should work for what you want. So your line could be (by expanding a and replacing t with c): rsync -rlpcgoDv --include="*/" --include="*.jpeg" --exclude="*" ~/alg/temperature/ ~/alg/tmp/

like image 151
Mike Avatar answered Oct 01 '22 22:10

Mike