Operating System - HP-UX
1822196 Members
3697 Online
109640 Solutions
New Discussion юеВ

Re: Problem about "rsync"

 
SOLVED
Go to solution
lin.chen
Frequent Advisor

Problem about "rsync"

My request is to sync the data between the two server.
rp7400 /source is my source data
rp8400 /dest is my destination data.
I want to sync /source directory to the directory /dest on the machine rp8400.
If any of the files already exist on the destination system then the rsync remote-update protocol is used to update the file by
sending only the differences.

I have install "rsync" on both servers.
Could you give me some sample to let me know how to use this tool name "rsync"

Thanks,louis

4 REPLIES 4
Patrick Wallek
Honored Contributor

Re: Problem about "rsync"

There should be numerous examples in the rsync man page (man rsync).

Here's the main rsync site:
http://samba.anu.edu.au/rsync/

Here's the rsync man page online:
http://samba.anu.edu.au/ftp/rsync/rsync.html

Here are other rsync examples:
http://samba.anu.edu.au/rsync/examples.html
Bill Hassell
Honored Contributor
Solution

Re: Problem about "rsync"

rsync is a very useful tool but the many, many options make it a bit tricky to navigate the man pages and documentation. Here is an example on the client (sending) side:

rsync -avz -e ssh \
--delete \
--exclude=.glancerc_hp \
--exclude=.sh_history \
--include=.ssh/authorized_hosts \
--exclude=.ssh/id* \
--exclude=.ssh/known_hosts \
--exclude=.sw \
--exclude=work \
--exclude=junk \
--exclude=adviser.out \
--exclude=Mail \
--exclude=.profile \
--exclude=pubring.gpg \
--exclude=secring.gpg \
--exclude=.gpmhp_atlig0 \
--exclude=.lsof_atlig0 \
--rsync-path=/usr/local/bin/rsync \
$HOME/ $MYSYS:$HOME

This example is used to sync all the files in $HOME (the user's home directory) to the same directory on $MYSYS -- where $MYSYS is the remote computer name. The -avz options are in the man page and you will need to choose your login method (ie, remsh/rsh or ssh). My example uses ssh and is recommended (but you must be running ssh on both machines). Notice the --delete (that's correct, two - signs in front of exclude, per the man page) will remove files that do not (or no longer) exist at the source. The --exclude= shows which source files and/or directories are to be ignored and not sent to the destination.

The -rsync option is a helper for the destination system to locate it's copy of rsync, normally not required but use if needed. The last two parameters are the source, but NOTICE THE TRAILING / on the first $HOME. This tells the destination not to start another directory at the destination, but to put everything into the last parameter, in this case $HOME with no trailing /.

Now before you run rsync on a really big and important source, test it in a /tmp directory. Change files on both ends and watch how rsync handles the additions, deletions and changes.


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: Problem about "rsync"

Shalom,

-e ssh ensures the data stream is encrypted.

Here is a rl example.

rsync -avH --stats --delete -e ssh /var/httpd/ $othernode:/var/httpd/


othernode variable is set to the destination node.

You might want to be careful with the --delete option

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
enrico.nic
Regular Advisor

Re: Problem about "rsync"

A small addition to what the gurus already reported, with an example:

/usr/bin/rsync -avuzgp \
--delete-after \
--exclude 'lost+found' \
--rsh=ssh \
--rsync-path=/usr/bin/rsync \ remote_host:/remote_dir \
/local_dir

--delete-after deletes after the transfer
--rsh=ssh the default is remote shell (rsh): use ssh instead of it
--rsync-path=/usr/bin/rsync if you are working with 2 different unix flavors (HP-UX locally, linux remotely in this example) this tells rsync where to find the rsync command remotely, otherwise it will not work (if the remote path of rsync is different from the local one)

hope this helps

Enrico