Only overwrite larger files
How does one copy files and in doing so only overwrite larger files? Date is to be ignored, only if names match and destination is smaller there's overwriting (and of course if the file doesn't exist in destination it's copied).
Thank you kindly |
man rsync
|
Quote:
|
Quote:
Because putting "rsync only copy larger files" into Google pulls up more than 265,000 hits with examples, and the man page on rsync also has several things that will let you dictate what to copy, under what conditions. |
Quote:
https://unix.stackexchange.com/quest...rite-if-larger amongst many others, still with nothing to help with my issue. Will you actually help with the OP? |
Rsync won't check the size, but it will check for changes in content and transfer the differences. So if the file gets smaller it will get updated just like if the file gets larger or if it changes content but stays the same size. The options to look for there are --archive, --hard-links, and --verbose. See the reference manual "man rsync" for details on those. There are other options which might be relevant depending on the quantity, size, and sparseness of the files to be transferred. Please write more about the characteristics of what you are transferring.
If you absolutely have to go by size then you'll have to script something, probably with find and stat in shell, if not Perl or Python. Either way, show us what you've tried and where you are stuck so we can see 1) what's going on and 2) which tools you are familiar with and your approximate skill level with them. That way you can get an answer more suited to your situation. |
Quote:
As turbocapitalist says, show us what you've done/tried first and we can assist from there. I would suggest reading the "Question Guidelines". |
what about --min-size ?
|
@pan64. This is not what the OP wants. Check the SE links discussed above.
|
Quote:
|
Quote:
You could probably find all files matching your requirements using the 'find' command, then delete them, then run your backup to replace the "missing" files. I imagine that would net you the same effect. The possible downside of that is that the deleted files will no longer be backed up until your backup operation is completed. But that probably isn't a problem, since you're wanting to replace them anyway. |
Quote:
Quote:
|
Quote:
Then you can pipe the output to rm. Then you can backup your newest file. Take this constructively: I don't want to do it all for you; I'm a big proponent of "teach a man to fish". |
Quote:
|
Quote:
You posted two links which almost do that in #5 above. Please say what is wrong with the second link, I mean in addition to it parsing of ls output. |
All times are GMT -5. The time now is 10:31 PM. |