LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2009, 11:16 AM   #1
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Rep: Reputation: 51
synchronize using rsync


hi

Howto synchronize a directory included all subdirectories between 2 linux machines (POWERPC)?

Last edited by cccc; 12-21-2009 at 11:17 AM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-21-2009, 11:33 AM   #2
tom4everitt
Member
 
Registered: Jan 2009
Location: Stockholm
Distribution: Fedora, Ubuntu, Mac OS X
Posts: 78

Rep: Reputation: 23
Basically

rsync -r local_dir user@othercomputer:dir_on_other_machine

or, if you want to sync in "the other direction", you can just switch the arguments to:

rsync -r user@othercomputer:dir_on_other_machine local_dir
 
1 members found this post helpful.
Old 12-25-2009, 09:02 AM   #3
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
Thx, but I have a questions:

How it works to transfer user rights and permissions as well?

Last edited by cccc; 12-25-2009 at 06:03 PM.
 
Old 12-26-2009, 02:53 AM   #4
tom4everitt
Member
 
Registered: Jan 2009
Location: Stockholm
Distribution: Fedora, Ubuntu, Mac OS X
Posts: 78

Rep: Reputation: 23
Then you should use the -a option instead of -r (a is for archive, r is for recursive). So what you write is:

Code:
rsync -a local_dir user@othercomputer:dir_on_other_machine

rsync -a user@othercomputer:dir_on_other_machine local_dir
also, beware of appending a slash to your 'from folder'. Its hard to explain the difference, but if you try to sync a folder with and without the slash, I think you'll get it.


EDIT:

You might wanna add the -u option as well, so that it doesn't copy files that have a newer modified time in the 'to directory'. Depends how you're going to use it I guess.

Last edited by tom4everitt; 12-26-2009 at 03:04 AM.
 
1 members found this post helpful.
Old 12-26-2009, 05:13 AM   #5
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
Thx, I've already done the following:
Code:
# rsync -e ssh -avzp --delete-after /support/ root@192.168.2.23:/support/
Do u think is not OK?

Should I better do this?
Code:
# rsync -e ssh -rvzp --delete-after /support root@192.168.2.23:/support
 
Old 12-26-2009, 06:59 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by cccc View Post
Do u think is not OK?

Should I better do this?
There is no a better or worse solution for us. It all depends on what do you want to achieve. If you want to have an exact copy of your original directory, including permissions, ownership, modification times and so on... you need the -a archive option. If you want to add verbosity use the -v option. If you want to compress data during the transfer use -z.

Read carefully the rsync help or the manual page: then you will be aware that -a equals to -rlptgoD and that you can avoid some redundancy in your command line options.
 
2 members found this post helpful.
Old 12-26-2009, 07:03 PM   #7
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by tom4everitt View Post
also, beware of appending a slash to your 'from folder'. Its hard to explain the difference, but if you try to sync a folder with and without the slash, I think you'll get it.
I don't know what u exactly mean.
Can u pls give some more details and an example?

THX
 
Old 12-27-2009, 04:30 AM   #8
tom4everitt
Member
 
Registered: Jan 2009
Location: Stockholm
Distribution: Fedora, Ubuntu, Mac OS X
Posts: 78

Rep: Reputation: 23
Quote:
Originally Posted by cccc View Post
I don't know what u exactly mean.
Can u pls give some more details and an example?

THX
Okay, let me try to explain it then :P

If you have a folder foo containing files a1, a2, a3, that you want to copy to another folder bar, then if you do:

rsync -r foo/ bar

bar will end up containing a1, a2, a3.

If you instead do:

rsync -r foo bar

bar will end up containing a folder named foo which in turn contains a1, a2, a3.

So appending a / or not too foo makes quite a difference. As long as you stick to one of the options you'll be quite safe, but it's important to know there's a difference (the cp command does not care about an appended slash).
 
1 members found this post helpful.
Old 12-27-2009, 08:58 AM   #9
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,678
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
It all depends on whether you want to put the source folder INSIDE the target folder, or put its CONTENTS inside the target folder. The traditional Unix logic used on the "cp" command depends on whether the target folder already exists or not.

The simple command "cp -r foo bar" (assuming "foo" exists and is a directory) will behave differently if "bar" does not exist, than if "bar" does exist (and is a directory). This behavior can be changed by appending "/." to the source directory. The effect of doing that is that you are changing the final name component of the source directory from "foo" to ".". It is that last name component that is the target inside "bar". But since "." names the directory it is in, the effect is that the source and target are peers and the source contents become the target contents.

The "rsync" command changes this somewhat by allowing appending just "/" (though "/." also works) to have the effect of making the source and target directories be peers.

You have to decide whether you want the source directory to be put INSIDE the target directory, or to just merge the source directory contents into the target directory contents. You must make this decision if the target exists. If the target does not exist, then it will always make the target as an equivalent to the source. You append the "/" or "/." or not, as appropriate. I always recommend using "/." instead of "/" in the case where appending them is desired, since "/." works on other commands like "cp", too (e.g. you only have to remember to append "/." for whatever command is used for copying).
 
3 members found this post helpful.
Old 12-27-2009, 10:53 AM   #10
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
THX
 
Old 12-28-2009, 03:35 AM   #11
tom4everitt
Member
 
Registered: Jan 2009
Location: Stockholm
Distribution: Fedora, Ubuntu, Mac OS X
Posts: 78

Rep: Reputation: 23
Quote:
Originally Posted by Skaperen View Post
It all depends on whether you want to put the source folder INSIDE the target folder, or put its CONTENTS inside the target folder. The traditional Unix logic used on the "cp" command depends on whether the target folder already exists or not.

The simple command "cp -r foo bar" (assuming "foo" exists and is a directory) will behave differently if "bar" does not exist, than if "bar" does exist (and is a directory). This behavior can be changed by appending "/." to the source directory. The effect of doing that is that you are changing the final name component of the source directory from "foo" to ".". It is that last name component that is the target inside "bar". But since "." names the directory it is in, the effect is that the source and target are peers and the source contents become the target contents.
.
Aah, interesting. I didn't know this.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync solaris + ld.so.1: rsync: fatal: libiconv.so.2: open failed: xxx_anuj_xxx Solaris / OpenSolaris 25 02-23-2012 03:23 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM
rsync to synchronize by time or size pericop Linux - Server 0 02-11-2007 10:26 AM
Rsync server vs rsync over ssh humbletech99 Linux - Networking 1 10-18-2006 12:10 PM
Windows Rsync Upload to Linux Rsync - permissions inspleak Linux - Software 0 10-12-2004 02:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration