LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to use Rsync? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-rsync-703762/)

your_shadow03 02-10-2009 11:12 PM

How to use Rsync?
 
I have a file pluto.sh on each machine(ubuntu Fiesty and Fedora 7).
Everytime developer update the file with codes to Fedora 7 machine.All I want is to rync it to Ubuntu Fiesty.
How can it be possible with rsync?

datopdog 02-11-2009 01:42 AM

Code:

rsync -avz file_name user@host:/path_to_store
you will need ssh keys installed as the default transport for rsync is ssh.

your_shadow03 02-11-2009 05:24 AM

I tested it manually in this way:

I created a folder called pit under /opt on ubuntu machine. Under that I create a file called kally.
I edited kally and wrote:
Code:

How are you ?
Now I went to Fedora Machine and created the same folder and file.I edited the same line.

Now On Ubuntu I ran the command:

Code:


rsync -avz kally vjs@fedora7:/opt/pit

It asked me for password and displayed:
Code:

building file list ... done
pit

sent 97 bytes  received 46 bytes  57.20 bytes/sec
total size is 14  speedup is 0.10

But I dint see any changes if I make any changes on one machine.
Correct me if I am wrong at the steps

datopdog 02-11-2009 05:33 AM

are you trying to sync both ways from what you have shown below it looks like you ran the command.

Code:

rsync -avz vjs@fedora7:/opt/pit kally
instead of

Code:

rsync -avz kally vjs@fedora7:/opt/pit
because it was pit that was transfered.

the general principal with rsync is

Code:

rsync -options <source> <destination>

your_shadow03 02-11-2009 06:00 AM

I am confused !!!

Lets make it more clear,
I have Ubuntu and Fedora Machine.
On Ubuntu I have file at /opt/linux and on fedora I have same file as /opt/linux.

I went to ubuntu machine:
And edited

Code:

#echo "hello" > linux
Now Help me where Should I run rsync on Ubuntu or Fedora?

your_shadow03 02-11-2009 06:14 AM

Its Working fine now.
I was mistaken at running command and now its working.
How can I proceed with ssh without providing password.
I followed http://troy.jdmz.net/rsync/index.html link but again it is asking for password.
Any idea why its behaving so?
I read the troubleshooting colum too but that dint help.

Pls Help

Didier Spaier 02-11-2009 06:23 AM

New issue => new thread

your_shadow03 02-11-2009 06:31 AM

if I am not wrong RSYNC with SSH do come under "How to RSync"
I could have asked for number of Questions related to RSYNC at single shot but I need to understand if I am wrong at my steps.Now as I am having rsync working I need a script for rsync without password.
So i dont think that would make any difference following up till my rsync gets working to the fullest.

Hope you will understand.

esaym 02-11-2009 08:44 AM

For password-less ssh log ins you must first create your ssh key for your local machine:

Code:

ssh-keygen -t rsa
Don't enter a password for it, just press enter a few times

Then upload the contents of the file /home/*user*/.ssh/id_rsa.pub to the file /home/*user*/.ssh/authorized_keys on the remote host (or /root/.ssh/authorized_keys for root log in)

Debian distros come with a nice tool to upload the key to the remote host:
Code:

ssh-copy-id -i ~/.ssh/id_rsa.pub username@remotehost
Here is a script I use to back up a box on my lan with:

Code:

rsync -av --delete-before --stats --progress --rsh='ssh -c arcfour -p22' root@10.36.39.1:/ /home/storage/BackUp/ --exclude="/proc/" --exclude="/lost+found/"  --exclude="/mnt/" --exclude="/dev/"
This connects to the server 10.36.39.1 with ssh using arcfour compression (faster) on port 22. It copies / from the whole server into the folder /home/storage/BackUp/ on my local machine.

Please be very careful with the "--delete-before" option. If you get mixed up, it can delete your whole hard drive. Before using --delete-before, run rsync with the -n option for a dry run that won't modify or transfer anything so you can see what will happen.

man rsync:
http://www.manpagez.com/man/1/rsync/

mrclisdue 02-11-2009 08:51 AM

edit: previous poster beat me to the punch, with similar instructions - no need to muddy the waters.

cheers,

Mountain 02-11-2009 11:08 PM

I'm interested in this topic too. However, my question is how to set this up so that rsync doesn't don't need to log in as root to do the backup.

(BTW, I'm actually using dervish, which uses rsync.)

I made /root/.ssh/authorize_keys and I have it working, but now I want to get the backup working without the root login.

Thanks for any help.

esaym 02-12-2009 10:37 AM

Quote:

Originally Posted by Mountain (Post 3440510)
I'm interested in this topic too. However, my question is how to set this up so that rsync doesn't don't need to log in as root to do the backup.

(BTW, I'm actually using dervish, which uses rsync.)

I made /root/.ssh/authorize_keys and I have it working, but now I want to get the backup working without the root login.

Thanks for any help.

Just ssh as a different user. In my example above instead of root@10.36.39.1, just change the user: someuser@10.36.39.1

Of course you would also have to add your id_rsa.pub key to /home/someuser/.ssh/authorize_keys

And of course if you don't log in as root, you might not be able to get access to some files...


All times are GMT -5. The time now is 05:15 PM.