What is the switch or option of rsync command inorder to skip the backup of corrupt files so that it does not overwrite good files?
-
3What is a corrupt file? Filesystem error while reading it? Something else? – Mat Feb 17 '16 at 13:22
-
What's your rsync command? – kba Feb 17 '16 at 13:23
-
@kba https://en.wikipedia.org/wiki/Rsync – Karthik Vee Feb 17 '16 at 13:25
-
:) No I mean the actual command you're executing and what files are created on source/target and which files should not be created. It's not clear from your question to me. – kba Feb 17 '16 at 13:27
-
Are the file corrupted before or during the `rsync` process? If it is before, you'd have to run a sanity check before passing the file to rsync. Alternatively I would suggest using a backup system like `backuppc` that allows for multiple backup intervals and takes file changes into consideration. – FelixJN Feb 17 '16 at 13:28
-
There is no universal way to test if a file is corrupted or not, so you need to design a specific test for specific file types, see http://unix.stackexchange.com/a/15169/95917. The most obvious option is to look through a directory then, list the corrupted files and make a script use `rsync`'s `--exclude` option. Are there specific file(s) type(s) you'd like to check? The script is not the problem, but the file type(s) needs specification. – Jacob Vlijm Feb 17 '16 at 14:04
-
1@JacobVlijm and Fiximan Thanks for your comments your explanations are helpful! – Karthik Vee Feb 18 '16 at 12:07
1 Answers
Rsync's business is creating and synchronizing mirrors of files, warts and all. It does not have any options to maybe not synchronize a file.
The only exception is that it will decline to delete any files if I/O errors lead it to suspect that even one file is only temporarily missing, but that's enabled by default, so you don't have to do anything. (You can disable the fail-safe with --ignore-errors).
However, rsync does take an option --files-from=FILE, where FILE can be - so you can pipe the names into stdin. You can therefore do your own corruption checks, and pipe only the good files into rsync for mirroring.
Warning: --files-from= implies various not-necessarily-obvious behaviour changes, so you should read the documentation carefully. You will also be unable to use --delete as there will be no way for rsync to tell the difference between files that no longer exist and files you chose not to list because they're corrupt. You also need to be careful about spaces in file names, so check out --from0.
- 5,707
- 1
- 19
- 27