Install and use rsync
rsync is a free software computer program for Unix and Linux like systems.
Using rsync we can take backup/mirroring a directory tree of files from one machine to another machine or in a same machine.
To install rsync:
In Ubuntu,
# apt-get install rsync
In CentOS/Fedora Core Linux,
# yum install rsync
rsync syntax:
rsync {source} {destination}
Options:
--delete : delete files that don't exist on sender (system)
-v : Verbose
-a : archive mode
-r : recurse into directories
-z : compress file data
Example:
In a single machine:
# rsync -avz /src/bar /data/tmp
This will transfer all files from the directory /src/bar to /data/tmp/bar directory.
# rsync -avz /src/bar/ /data/tmp
This will transfer all files from the directory /src/bar to /data/tmp/.
"/" (slash) on a source means "copy the contents of this directory".
From a local computer to a remote server:
rsync -avz --rsh='ssh -p{ssh-port.no}' {source} {remote machine IP}:{destination}
example:
rsync -avz --rsh='ssh -p2222' /src/bar/ 192.168.1.1:/data/tmp/
If the remote server using default port(22):
rsync -avz -e ssh /src/bar/ 192.168.1.1:/data/tmp/
.
0 comments:
Post a Comment