synchronize using rsync
hi
Howto synchronize a directory included all subdirectories between 2 linux machines (POWERPC)? |
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 |
Thx, but I have a questions:
How it works to transfer user rights and permissions as well? |
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 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. |
Thx, I've already done the following:
Code:
# rsync -e ssh -avzp --delete-after /support/ root@192.168.2.23:/support/ Should I better do this? Code:
# rsync -e ssh -rvzp --delete-after /support root@192.168.2.23:/support |
Quote:
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. |
Quote:
Can u pls give some more details and an example? THX |
Quote:
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). |
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). |
THX
|
Quote:
|
All times are GMT -5. The time now is 11:58 AM. |