Operating System - Linux
1825775 Members
2142 Online
109687 Solutions
New Discussion

Re: Synchronize 2 linux machines using rsync

 
SOLVED
Go to solution
'chris'
Super Advisor

Synchronize 2 linux machines using rsync

hi

I'd like to synchronize a directory included all subdirectories with user rights and permissions between 2 linux server using rsync.
13 REPLIES 13
Steven Schweda
Honored Contributor
Solution

Re: Synchronize 2 linux machines using rsync

You have my permission. What's stopping you?
'chris'
Super Advisor

Re: Synchronize 2 linux machines using rsync

I mean UNIX (linux) directory and file permissions.
Normally u can change it using chmod command.
Steven Schweda
Honored Contributor

Re: Synchronize 2 linux machines using rsync

So, what's the problem? Is there something
unclear in the rsync documentation? Can you
find no rsync examples by searching the ITRC
forums? Is Google broken? Are you too tired
to read this stuff yourself?
Michal Kapalka (mikap)
Honored Contributor

Re: Synchronize 2 linux machines using rsync

'chris'
Super Advisor

Re: Synchronize 2 linux machines using rsync

I've tried the following:

rsync -e ssh -avzp --delete-after /repl/ root@192.168.0.3:/repl/
root@192.168.0.3's password:

and hope it's OK.

BTW Howto set as a cron job using password?
Michal Kapalka (mikap)
Honored Contributor

Re: Synchronize 2 linux machines using rsync


BTW Howto set as a cron job using password?

#==========================================

what you mean ????

you like to make a cron job for this rsync password less ???


if yes you need to use password less ssh connection :

http://www.cyberciti.biz/faq/ssh-password-less-login-with-dsa-publickey-authentication/

mikap

'chris'
Super Advisor

Re: Synchronize 2 linux machines using rsync

Thx, I've created password less SSH and setuped this command as a cron job:

rsync -e ssh -avzp --delete-after /repl/ root@192.168.0.3:/repl/

I hope this rsync command is OK to have an exact copy of my original directory, including permissions, ownership, modification times and so.

If not, pls correct me.
Michal Kapalka (mikap)
Honored Contributor

Re: Synchronize 2 linux machines using rsync

hi.

this command should work.

your - p switch should take care about permition :

-p, --perms
This option causes the receiving rsync to set the destination
permissions to be the same as the source permissions. (See also
the --chmod option for a way to modify what rsync considers to
be the source permissions.)



mikap
Steven Schweda
Honored Contributor

Re: Synchronize 2 linux machines using rsync

> I hope this rsync command is OK [...]

Have you considered running a test using some
small directory tree? You might even add or
change a file and see what happens.
Sometimes running a quick experiment can be
more reliable than either hope or someone
else's opinion. Often faster, too.
'chris'
Super Advisor

Re: Synchronize 2 linux machines using rsync

THX

I've done a test and it seems to work well.
Steven E. Protter
Exalted Contributor

Re: Synchronize 2 linux machines using rsync

Shalom Chris,

Might want to try this:

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


Othernode is the target host.

You can vary the directory source and target to your hearts content.

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
'chris'
Super Advisor

Re: Synchronize 2 linux machines using rsync

Thx to ALL, but have a question:

rsync -e ssh -avzp ...

does it transfer each time all files or just differences?

BTW I need the same permissions on the target like on the source, that's the reason why I need -p option.
Steven Schweda
Honored Contributor

Re: Synchronize 2 linux machines using rsync

> does it transfer each time all files or
> just differences?

man rsync

http://samba.anu.edu.au/rsync/documentation.html
http://samba.anu.edu.au/rsync/FAQ.html

I quote:

If you think that rsync is copying too
many files, look at the itemized output
(-i) to see why rsync is doing the
update [...]