How to make rsync right ?
Due to a first rsync "error" where I have two files with the
"same" name "Linux" and "linux", rsync always get confused when I do subsequent rsync, even though I have merged Linux and linux and remove the redundant file. How can I ask rsync to forget the former mistakes ? Quote:
|
You could add the "--delete" option to rsync. This will of course wipe out files that have been deleted in the source folders.
|
Thanks. I think --delete is a neat way to preserve identical content
between the source and the dest. Your "wipe out" actually means wiping out some files in the destination directory. I did some simple tests, I still cannot explain the behavior I have seen in the first post. I mean it should not happen since I have delete one file from the source directory. Well, I think there is some weird things that is very subtle. Anyway, I think from now on I will use --delete whenever I can. Thanks! |
Now I figured out what went wrong !
My active directory is summary/ but I have another copy of that under junk-summ. I removed the redundancy in summary/, but not the ones in junk-summ, hence it created an illusion that something is wrong with rsync. So rsync is working fine, of course! At least I figured out the mystery, bummer!! Another, the "--delete " is a good way of making identical copy, appreciate propofol's comment ! |
The --delete option can also be dangerous. If you accidentally type the wrong source directory name, you could end up deleting all the target files (and have to reload everything all over again).
The --dry-run option is useful to test with to make sure you are doing what you think you are doing. Then recall the command and pull off the --dry-run option when ready to do it. Something that often happens to people is that they run rsync a second time and find they have a duplicate file tree of their files inside the target directory, with a name the same as the directory. This is because rsync follows the legacy Unix behaviour of putting a source directory INSIDE a target directory when the target already exists. To make this not happen, simply append "/." to the source directory name. This causes rsync to access "." inside the target directory, which is the target itself. You can also use this trick on cp and scp commands. |
Good pointer with dry-run!!
Quote:
destroyed (such as months of simulation results and that is the only copy). It is also true with the basic cp. Since I just learned rsync, I choose to alias the rsync command and intend to restrict the number of such aliases. I notice that between two machines with different rsync versions, it is only possible to issue rsync command on the machine with a newer version. |
All times are GMT -5. The time now is 04:31 AM. |