Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help learning rsync

Status
Not open for further replies.

ejaggers

Programmer
Feb 26, 2005
148
US
I want to move some files in /etc from box pentapp1 to boxes pentapp2 and pentinf1.
I also want to create /home directories from pentapp1 if they don’t exist on pentapp2 and pentinf1, but not copy the contents of the directory. I can’t find a tutorial that is helpful.

To get the feel of rsync I’ve done the following using RSYNC_PASSWORD=”mypasswd”, but it still asked for a passwd. What am I doing wrong?

Code:
export RSYNC_PASSWORD=”mypasswd”
rsync -avz *.unl pentapp2:/home/ejaggers/Tmp
 
The RSYNC_PASSWORD option only applies if you are connecting to an rsync server, which is probably not true in your case; under normal operation rsync transports data across an ssh or rsh connection.

rsync is in fact not the most convenient tool for replicating directories since it is designed more to deal with the files contained therein.

Something like this may be more appropriate:

Code:
find /home/* -type d -prune | cpio -o | ssh pentapp2 cpio -idv

Obviously you will need to set up SSH keys to run this non-interactively. cpio is an archiver much like tar, but it has some useful features that tar does not.

Annihilannic.
 
Okay, I tried to setup ssh based on tutorial, " I got to "Using the ssh-agent program", and got lost, because which ssh-add gave (/usr/bin/ssh-add), but ssh-add gave this: Could not open a connection to your authentication agent.

And now:
export RSYNC_PASSWORD="mypasswd"
rsync -avz *.unl pentapp2:/home/ejaggers/Tmp

gives:
Enter passphrase for key '/root/.ssh/id_dsa':
 
Annihilannic,

I got rsync to work thanks to the tip above. As you probably already know, this thread is piggy backing:

which is about keeping users in sync between 3 boxes. Please check out the script below, and tell me what you think. Thanks in advance

Code:
#from pentapp1 / root cron:
export RSYNC_PASSWORD="mypasswd"
rsync -avz /etc/pass* pentapp2:/etc        # moves passwd passwd-
rsync -avz /etc/*shadow* pentapp2:/etc     # moves shadow shadow- gshadow gshadow- 

# create any missing home dir's
find /home/* -type d -prune | cpio -o | ssh pentapp2 cpio -idv
 
Annihilannic (MIS)

Oh, I forgot about: rsync -avz /etc/group pentapp2:/etc
 
Annihilannic, I'm stumped again. I followed the instructions in for both, and Linux to Linux works fine. But Linux to Unix fails. Any ideas? I was just test rsync on Unix, but if it works I'll be going Linux to Linus anyway. I make a root dir on irv001.

Code:
pentapp1/root>rsync -avz ecj pentapp2:/root
building file list ... done
ecj

sent 98 bytes  received 42 bytes  280.00 bytes/sec
total size is 9  speedup is 0.06

pentapp1/root>rsync -avz ecj irv001:/root
root@irv001's password:
/bin/ksh: rsync:  not found
Connection to irv001 closed by remote host.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(463) [sender=2.6.8]

ssh root@irv001 logs me on when i supply the passwd. And rsync is not on Unix, does that matter?

irv001>ls -l .ssh
total 1
-rw------- 1 root system 818 Sep 4 10:56 authorized_keys
 
Yes, it matters, you need a copy of rsync installed at both ends. If it is in a directory that is not in the default PATH at the remote end, you can specify the location of the rsync binary using the --rsync-path=/some/path/to/rsync option.

Annihilannic.
 
I do have a very good tutorial on my personal blogs for rsync usage...

Hope it can help

Regards

Polani

Here comes polani Once again!!!

See my personal blogs at
for unique solutions and tips on AIX, Linux,Storage and TSM.
 
Annihilannic and polani, I'm in class all week. I'll try this again next week. Thanks for your responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top