LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to make rsync right ? (https://www.linuxquestions.org/questions/linux-software-2/how-to-make-rsync-right-777366/)

centguy 12-21-2009 11:46 PM

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:

mbp15$ rsync -avz name@centos52-64-fuj:/media/ext3-datadisk .
receiving file list ... done
ext3-datadisk/junk-summ/summary/man/linux
ext3-datadisk/junk-summ/summary/prog/quicksort.f
ext3-datadisk/junk-summ/summary/tex/eps/Si2-2x2x2-Conventional-UnitCell.agr
ext3-datadisk/junk-summ/summary/tex/eps/Si2-2x2x2-Conventional-UnitCell.eps
ext3-datadisk/summary/prog/068-Displace-TestForce-NRL-TB-01/75-Displace-TestForce-VASP-oddN1/IBZKPT

sent 1384 bytes received 1733053 bytes 495553.43 bytes/sec
total size is 28749153321 speedup is 16575.50


mbp15$ rsync -avz name@centos52-64-fuj:/media/ext3-datadisk .
receiving file list ... done
ext3-datadisk/junk-summ/summary/man/Linux
ext3-datadisk/junk-summ/summary/prog/quicksort.F
ext3-datadisk/junk-summ/summary/tex/eps/Si2-2x2x2-conventional-unitcell.agr
ext3-datadisk/junk-summ/summary/tex/eps/Si2-2x2x2-conventional-unitcell.eps
ext3-datadisk/summary/prog/068-Displace-TestForce-NRL-TB-01/75-Displace-TestForce-VASP-oddN1/ibzkpt

sent 574 bytes received 1748460 bytes 499724.00 bytes/sec
total size is 28749153321 speedup is 16437.16

propofol 12-22-2009 12:05 AM

You could add the "--delete" option to rsync. This will of course wipe out files that have been deleted in the source folders.

centguy 12-22-2009 12:38 AM

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!

centguy 12-22-2009 02:18 AM

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 !

Skaperen 12-22-2009 08:52 AM

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.

centguy 12-22-2009 06:37 PM

Good pointer with dry-run!!


Quote:

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).
Very true, especially when important files that are supposed to be duplicated are
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.