Portal Home > Knowledgebase > Articles Database > second time to run rsync?
second time to run rsync?
Posted by surfmanjoe, 07-08-2007, 03:15 PM |
one day later, if I run the following command again, the command is same as the one run by the first time.
rsync -avz username@IP:/home/asite/public_html/ /home/asite/public_html/
does it mean rsync will just check and copy the newer folders and files from the last copy?
thanks.
|
Posted by Linuxsurgeon, 07-08-2007, 04:00 PM |
The second time it will copy only those files which were changed or created from the earlier copy made.
|
Posted by Jakiao, 07-08-2007, 09:33 PM |
Linuxsurgeon is incorrect.
The command you're using does not specify the -u flag which transfers only updated files. Without -u, it will retransfer everything regardless of whether or not it was changed (waste of bandwidth and time).
You might want to use "-arzgopu" for the flags. If you would like to delete files that no longer exist on the source server, add "--delete".
|
Posted by foobic, 07-08-2007, 09:38 PM |
No, linuxsurgeon was correct - copying only changed files is the rsync default. Read up on the -u option - it's actually about updating newer files.
|
Posted by Jakiao, 07-08-2007, 09:49 PM |
The person asked:
All he wants it to do is copy the newer files from the last. Using just "-avz" will resync everything. There is no checking. You need "-u" to copy JUST newer files. That is: files which have a newer modification time on the source server, files which exist on the source but not the target, any differences between source and target servers.
This is exactly what the poster asked for.
From CLI:
[root@backup network-scripts]# rsync --help | grep "\-u"
-u, --update update only (don't overwrite newer files)
From "man rsync":
-u, --update
This forces rsync to skip any files for which the destination file already exists and has a date later than the
source file.
In the currently implementation, a difference of file format is always considered to be important enough for an
update, no matter what date is on the objects. In other words, if the source has a directory or a symlink where
the destination has a file, the transfer would occur regardless of the timestamps. This might change in the future
(feel free to comment on this on the mailing list if you have an opinion).
|
Posted by foobic, 07-08-2007, 10:10 PM |
rsync by default will resync everything - agreed. However resyncing does not mean re-transferring, it means transferring just the changed files, which is what most people want, including, I believe, the OP.
In this default usage if a file at the destination is newer than the one at the source, the newer file will get overwritten. Where the destination is a backup of some kind this is not an issue because it should never be changed except by rsync. However in special cases you might want to be able to update a file on the destination directory and not have that updated file overwritten by rsync, in which case you can use the -u flag.
If you seriously think rsync -avz re-transfers every file every time then try it for yourself and look at the rsync output.
|
Posted by HD Fanatic, 07-09-2007, 01:27 AM |
I never had to use the -u in my rsync. It just transfer files that were changed, not having to copy everything over again after the first time.
|
Add to Favourites Print this Article
Also Read
RAID 1 (Views: 790)