LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 10-14-2012, 10:29 PM   #1
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Rep: Reputation: Disabled
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
 
Old 10-15-2012, 12:28 AM   #2
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
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
 
Old 10-15-2012, 12:51 AM   #3
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Original Poster
Rep: Reputation: Disabled
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

Last edited by Rupadhya; 10-15-2012 at 12:52 AM. Reason: missed a /
 
Old 10-15-2012, 01:16 AM   #4
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
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
 
Old 10-15-2012, 07:25 AM   #5
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Original Poster
Rep: Reputation: Disabled
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
 
Old 10-15-2012, 08:07 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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)
 
  


Reply

Tags
crontab, rsync, rsync+ssh



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
crontab rsync backup across servers secretlydead Linux - Server 2 04-03-2012 02:35 PM
[SOLVED] cron job - run a backup then rsync results to mounted drive lukester Linux - Newbie 8 03-28-2012 06:53 PM
[SOLVED] large tar nightly + rsync to compare question sir-lancealot Linux - Server 5 01-05-2011 02:28 PM
Crontab rsync does not backup to NAS device Astol Linux - Software 1 09-24-2008 12:04 AM
Backup with rsync and crontab gjblackford Linux - General 4 01-04-2007 08:53 AM

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

All times are GMT -5. The time now is 11:20 AM.

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