LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How do I get rsync to run in root's crontab for a nightly backup? (http://www.linuxquestions.org/questions/linux-networking-3/how-do-i-get-rsync-to-run-in-roots-crontab-for-a-nightly-backup-4175432231/)

Rupadhya 10-14-2012 10:29 PM

How do I get rsync to run in root's crontab for a nightly backup?
 
Hello,

After several hours of work, I finallly got rsync daemon to work on two machines. I can rsync from a bash script as a normal user (yay!). There are currently two machines in the network. They both run Fedora 17, and I am using rsync to perform a backup of certain directories.

I have built this script.
Code:

#!/bin/bash
#  testRsync.sh script
rsync -atl -v --stats /home/raj/Videos/*.webm  raj@192.168.1.1:/home/raj/Videos/

This is executed on MachineB which is IP address 192.168.1.104.

I start a terminal and it executes fine from the prompt.

I have added it to roots crontab and I get this error.
Quote:

opening connection using: ssh -l raj 192.168.1.1 rsync --server -vvvlogDtpre.iLsf . /home/raj/Videos/
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
[sender] _exit_cleanup(code=12, file=io.c, line=605): about to call exit(12)
My guess is it is unable to resolve the rsa key to connect rsync without a password. Any rsync experts out there? Your help is appreciated.

- Raj Upadhyaya

arun5002 10-15-2012 12:28 AM

You can use below commandline,But it was not advised to use in script .First check out whether you had configured ssh passwordless Login working fine between two system



#!/bin/bash

rsync --rsh="sshpass -p 123@ ssh -l root" 10.200.2.2:/opt/apps/bkup/daily/* /tmp

Rupadhya 10-15-2012 12:51 AM

Hmmm. I get
Code:

$ #!/bin/bash
$
$ rsync --rsh="sshpass -p 123@ ssh -l root" 10.200.2.2:/opt/apps/bkup/daily/* /tmp
rsync: Failed to exec sshpass: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(84) [Receiver=3.0.9]
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in IPC code (code 14) at io.c(605) [Receiver=3.0.9]

I tried changing the IP to 192.168.1.1 and the directory to /home/raj/backup/* but I think the problem is I am missing sshpass.
- Raj

arun5002 10-15-2012 01:16 AM

Hi


rsync: Failed to exec sshpass: No such file or directory (2)
Quote:


You have to install sshpass .Im not sure you find sshpass in Epel Repository

Rupadhya 10-15-2012 07:25 AM

Code:

yum provides sshpass*
Loaded plugins: auto-update-debuginfo, downloadonly, fastestmirror, langpacks,
              : presto, refresh-packagekit, tidy-cache
Google                                                  |  951 B    00:00   
adobe-linux-i386                                        |  951 B    00:00   
fedora-chromium                                          | 3.4 kB    00:00   
fedora-chromium-stable                                  | 3.4 kB    00:00   
fedora-cinnamon                                          | 2.9 kB    00:00   
google-chrome                                            |  951 B    00:00   
rpmfusion-free-updates                                  | 3.3 kB    00:01   
rpmfusion-free-updates-debuginfo                        | 2.7 kB    00:00   
rpmfusion-nonfree-updates                                | 3.3 kB    00:00   
rpmfusion-nonfree-updates-debuginfo                      | 2.7 kB    00:00   
updates/metalink                                        |  17 kB    00:00   
updates-debuginfo/metalink                              |  14 kB    00:00   
Loading mirror speeds from cached hostfile
 * fedora: mirrors.servercentral.net
 * fedora-debuginfo: mirrors.servercentral.net
 * rpmfusion-free: mirror.web-ster.com
 * rpmfusion-free-debuginfo: mirror.web-ster.com
 * rpmfusion-free-updates: mirror.web-ster.com
 * rpmfusion-free-updates-debuginfo: mirror.web-ster.com
 * rpmfusion-nonfree: mirror.web-ster.com
 * rpmfusion-nonfree-debuginfo: mirror.web-ster.com
 * rpmfusion-nonfree-updates: mirror.web-ster.com
 * rpmfusion-nonfree-updates-debuginfo: mirror.web-ster.com
 * updates: mirror.unl.edu
 * updates-debuginfo: mirrors.servercentral.net
sshpass-1.05-2.fc17.i686 : Non-interactive SSH authentication utility
Repo        : fedora
Matched from:
Other      : sshpass = 1.05-2.fc17
Other      : sshpass(x86-32) = 1.05-2.fc17



sshpass-debuginfo-1.05-2.fc17.i686 : Debug information for package sshpass
Repo        : fedora-debuginfo
Matched from:
Other      : sshpass-debuginfo(x86-32) = 1.05-2.fc17
Other      : sshpass-debuginfo = 1.05-2.fc17

so I installed
Quote:

yum -y install sshpass-1.05-2.fc17.i686
I then ran your command, modified for my system...
Code:

rsync --rsh="sshpass -p {mypassword_secret}@ ssh -l raj" 192.168.1.1:/home/raj/backup/* /tmp
Which ran without error.

- Raj

pan64 10-15-2012 08:07 AM

So you have rsyncd installed. You do not need ssh at all, you can use rsync shares: rsync -atl -v --stats /home/raj/Videos/*.webm host::share will work also (or similar)


All times are GMT -5. The time now is 02:29 PM.