Google
 

9/21/08

Using rsync to synchronize the files.

rsync -autv username@xxx.xxx.xxx.edu:/source_directory/ ./dest_directory

Use "-autv" options. This will make sure that if the files in the dest_directory is newer, it will not be overwritten.
"t" will preserve the time stamp.
"a" archive
"u" update; skip files that are newer on the receiver
"v" print out information

Another thing needs to be careful is that "/" after source_directory is needed if you want to synchronize the files inside source_directory. If "/" is ignored, then source_directory will be copied to dest_directory.

For example: If you have source_directory inside which you have source1, source2 two files. Now you want to synchronize the files with your directory "dest_dir" which at this moment is empty.

> rsync -autv ./source_directory/ ./dest_dir
The above command will copy source1 and source2 to ./dest_dir (since at this moment ./dest_dir is still empty, so the files inside ./source_directory is newer).

What if you want to exclude ./tmp directory?
> rsync -autv --exclude "tmp/" ./source_directory/ ./dest_dir
temp
is relative to the directory you are trying to backup, which is ./source_directory/ here.


> rsync -autv ./source_directory ./dest_dir
However, the above command will copy ./source_directory to ./dest_dir. It copy it as a directory. After the command, inside your ./dest_dir you will have another folder called "source_directory".

No comments: