public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] rsync via ssh
@ 2007-11-03 20:36 Roger Mason
  2007-11-04 15:24 ` Dirk Heinrichs
  2007-11-04 23:40 ` Shawn Haggett
  0 siblings, 2 replies; 16+ messages in thread
From: Roger Mason @ 2007-11-03 20:36 UTC (permalink / raw
  To: gentoo-user

Hello,

I'm trying to use rsync to back up my home directory on "mymachine" to another
machine (backup_machine) using a cron job.

This is the crontab entry (in rmason's crontab):

0,15,30,45 * * * *      rmason /usr/bin/rsync -av /home/rmason backup_machine:mymachine_rmason

The logs on backup_machine show entries like this when the cron job runs:

Nov  3 17:30:06 backup_machine sshd[22048]: error: PAM: Authentication failure for rmason from mymachine.esd.mun.ca
Nov  3 17:30:06 backup_machine sshd(pam_unix)[22052]: authentication failure;
     logname= uid=0 euid=0 tty=ssh ruser= rhost=mymachine.esd.mun.ca
     user=rmason

I have passwordless ssh between mymachine and backup_machine and the
rsync command in the crontab runs perfectly from the command line.

Does someone know what else needs to be done to get this (seemingly
simple!) task to work?

Many thanks,
Roger
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE:  [gentoo-user] rsync via ssh
@ 2007-11-03 21:06 Richard Ruth
  2007-11-04 14:54 ` Roger Mason
  0 siblings, 1 reply; 16+ messages in thread
From: Richard Ruth @ 2007-11-03 21:06 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]


Try adding "-e ssh" to your rsync command.
Search for "-e" in the rsync man page for an example.


=======================

This is the crontab entry (in rmason's crontab):

0,15,30,45 * * * *      rmason /usr/bin/rsync -av /home/rmason backup_machine:mymachine_rmason
I have passwordless ssh between mymachine and backup_machine and the
rsync command in the crontab runs perfectly from the command line.

Does someone know what else needs to be done to get this (seemingly
simple!) task to work?

[-- Attachment #2: Type: text/html, Size: 554 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-03 21:06 [gentoo-user] rsync via ssh Richard Ruth
@ 2007-11-04 14:54 ` Roger Mason
  2007-11-04 17:59   ` Steve Dommett
  2007-11-04 18:13   ` Ralph Slooten
  0 siblings, 2 replies; 16+ messages in thread
From: Roger Mason @ 2007-11-04 14:54 UTC (permalink / raw
  To: gentoo-user

Hi Richard,

Richard Ruth <richgentoo@pacbell.net> writes:

> Try adding "-e ssh" to your rsync command.
> Search for "-e" in the rsync man page for an example.
> =======================
> This is the crontab entry (in rmason's crontab):
> 0,15,30,45 * * * *      rmason /usr/bin/rsync -av /home/rmason backup_machine:my
> machine_rmason

Thanks for the reply.  Unfortunately that did not work, the same error
ocurs.  

This is what I have currently:
0,15,30,45 * * * *	/usr/bin/rsync -av -e "ssh" /home/rmason rmason@backup_machine:mymachine_rmason

I've tried with and without the quotes plus with and without the
rmason@ but none worked.

I think I'll try scp and see what happens.

Cheers,
Roger
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-03 20:36 [gentoo-user] rsync via ssh Roger Mason
@ 2007-11-04 15:24 ` Dirk Heinrichs
  2007-11-04 18:44   ` Roger Mason
  2007-11-04 23:40 ` Shawn Haggett
  1 sibling, 1 reply; 16+ messages in thread
From: Dirk Heinrichs @ 2007-11-04 15:24 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

Am Samstag, 3. November 2007 schrieb Roger Mason:
> Hello,
>
> I'm trying to use rsync to back up my home directory on "mymachine" to
> another machine (backup_machine) using a cron job.

Which cron?

> This is the crontab entry (in rmason's crontab):
>
> 0,15,30,45 * * * *      rmason /usr/bin/rsync -av /home/rmason
> backup_machine:mymachine_rmason

Shouldn't this be 

0,15,30,45 * * * * /usr/bin/rsync -av /home/rmason 
backup_machine:mymachine_rmason

HTH...

	Dirk

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 14:54 ` Roger Mason
@ 2007-11-04 17:59   ` Steve Dommett
  2007-11-04 18:46     ` Roger Mason
  2007-11-04 18:13   ` Ralph Slooten
  1 sibling, 1 reply; 16+ messages in thread
From: Steve Dommett @ 2007-11-04 17:59 UTC (permalink / raw
  To: gentoo-user

On Sunday 04 November 2007, Roger Mason wrote:
> Thanks for the reply.  Unfortunately that did not work, the same error
> ocurs.
This may not be applicable, but I run rdiff-backup from cron on many machine 
with no problems at all.  It uses librsync, so may be of interest to you.
http://rdiff-backup.nongnu.org/
If you ignore the 'rdiff-backup-data' folder it creates then it's more or less 
identical to using rsync alone.

HTH,
  Steve.
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 14:54 ` Roger Mason
  2007-11-04 17:59   ` Steve Dommett
@ 2007-11-04 18:13   ` Ralph Slooten
  2007-11-04 18:50     ` Roger Mason
  2007-11-04 19:07     ` Neil Walker
  1 sibling, 2 replies; 16+ messages in thread
From: Ralph Slooten @ 2007-11-04 18:13 UTC (permalink / raw
  To: gentoo-user

I have done a similar thing at work, except what I do is first create an 
ssh tunnel, then rsync to the locally listening port. Works perfectly. 
In my setup the remote server is running an SSH server which is not 
accessible directly. Maybe this will help you.


#!/bin/bash
SSL_COMMAND="ssh -p 2222 sshuser@myserver -f -N -L 8000:localhost:873"
SSL_PID=`ps aux | grep "$SSL_COMMAND" | egrep -v 'grep' | awk '{print $2}'`

if [ "$SSL_PID" == "" ]; then
         echo "=> Creating SSH tunnel to myserver"
         $SSL_COMMAND
         SSL_PID=`ps aux | grep "$SSL_COMMAND" | egrep -v 'grep' | awk 
'{print $2}'`
else
         echo "=> SSH tunnel already exists. Using existing tunnel."
fi

if [ "$SSL_PID" != "" ]; then
         echo "=> Connecting through SSH tunnel with PID $SSL_PID"
         rsync rsync://localhost:8000/wwwroot 
/mnt/samba/hotcopy/myserver/wwwroot \
         -rvtzp --delete --modify-window=1

         echo "=> Closing SSH tunnel"
         kill $SSL_PID
else
         echo "ERROR: SSH Connection failed! The backup could not complete"
fi



Cheers,
Ralph

Roger Mason wrote:
> Hi Richard,
> 
> Richard Ruth <richgentoo@pacbell.net> writes:
> 
>> Try adding "-e ssh" to your rsync command.
>> Search for "-e" in the rsync man page for an example.
>> =======================
>> This is the crontab entry (in rmason's crontab):
>> 0,15,30,45 * * * *      rmason /usr/bin/rsync -av /home/rmason backup_machine:my
>> machine_rmason
> 
> Thanks for the reply.  Unfortunately that did not work, the same error
> ocurs.  
> 
> This is what I have currently:
> 0,15,30,45 * * * *	/usr/bin/rsync -av -e "ssh" /home/rmason rmason@backup_machine:mymachine_rmason
> 
> I've tried with and without the quotes plus with and without the
> rmason@ but none worked.
> 
> I think I'll try scp and see what happens.
> 
> Cheers,
> Roger
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 15:24 ` Dirk Heinrichs
@ 2007-11-04 18:44   ` Roger Mason
  0 siblings, 0 replies; 16+ messages in thread
From: Roger Mason @ 2007-11-04 18:44 UTC (permalink / raw
  To: gentoo-user

Hi Dirk,

Dirk Heinrichs <dirk.heinrichs@online.de> writes:

> Am Samstag, 3. November 2007 schrieb Roger Mason:
>> Hello,
>>
>> I'm trying to use rsync to back up my home directory on "mymachine" to
>> another machine (backup_machine) using a cron job.
>
> Which cron?

vixie-cron

>> This is the crontab entry (in rmason's crontab):
>>
>> 0,15,30,45 * * * *      rmason /usr/bin/rsync -av /home/rmason
>> backup_machine:mymachine_rmason
>
> Shouldn't this be 
>
> 0,15,30,45 * * * * /usr/bin/rsync -av /home/rmason 
> backup_machine:mymachine_rmason

I already tried it without the rmason prepended to the command: no
difference.  FWIW I tried scp and had the same problems.  I think it
has to do with the backup_machine not reading my public ssh key, maybe
because the session is not interactive.

Thanks,
Roger 
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 17:59   ` Steve Dommett
@ 2007-11-04 18:46     ` Roger Mason
  2007-11-04 19:04       ` Steve Dommett
  0 siblings, 1 reply; 16+ messages in thread
From: Roger Mason @ 2007-11-04 18:46 UTC (permalink / raw
  To: gentoo-user

Hi Steve,

Steve Dommett <steve@st4vs.net> writes:

> On Sunday 04 November 2007, Roger Mason wrote:
>> Thanks for the reply.  Unfortunately that did not work, the same error
>> ocurs.
> This may not be applicable, but I run rdiff-backup from cron on many machine 
> with no problems at all.  It uses librsync, so may be of interest to you.
> http://rdiff-backup.nongnu.org/
> If you ignore the 'rdiff-backup-data' folder it creates then it's more or less 
> identical to using rsync alone.

Thanks, I'll have a look at it.

Did you have to do anything special to make it work from cron?

Cheers,
Roger
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 18:13   ` Ralph Slooten
@ 2007-11-04 18:50     ` Roger Mason
  2007-11-04 19:07     ` Neil Walker
  1 sibling, 0 replies; 16+ messages in thread
From: Roger Mason @ 2007-11-04 18:50 UTC (permalink / raw
  To: gentoo-user

Hi Ralph,

Ralph Slooten <axllent@gmail.com> writes:

> I have done a similar thing at work, except what I do is first create
> an ssh tunnel, then rsync to the locally listening port. Works
> perfectly. In my setup the remote server is running an SSH server
> which is not accessible directly. Maybe this will help you.
>
>
> #!/bin/bash
> SSL_COMMAND="ssh -p 2222 sshuser@myserver -f -N -L 8000:localhost:873"
> SSL_PID=`ps aux | grep "$SSL_COMMAND" | egrep -v 'grep' | awk '{print $2}'`
>
> if [ "$SSL_PID" == "" ]; then
>         echo "=> Creating SSH tunnel to myserver"
>         $SSL_COMMAND
>         SSL_PID=`ps aux | grep "$SSL_COMMAND" | egrep -v 'grep' | awk
> {print $2}'`
> else
>         echo "=> SSH tunnel already exists. Using existing tunnel."
> fi
>
> if [ "$SSL_PID" != "" ]; then
>         echo "=> Connecting through SSH tunnel with PID $SSL_PID"
>         rsync rsync://localhost:8000/wwwroot
> /mnt/samba/hotcopy/myserver/wwwroot \
>         -rvtzp --delete --modify-window=1
>
>         echo "=> Closing SSH tunnel"
>         kill $SSL_PID
> else
>         echo "ERROR: SSH Connection failed! The backup could not complete"
> fi

Another responder suggested rdiff-backup.  I'll give that a try first.

Thanks,
Roger
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 18:46     ` Roger Mason
@ 2007-11-04 19:04       ` Steve Dommett
  0 siblings, 0 replies; 16+ messages in thread
From: Steve Dommett @ 2007-11-04 19:04 UTC (permalink / raw
  To: gentoo-user

On Sunday 04 November 2007, Roger Mason wrote:
> Did you have to do anything special to make it work from cron?

No, but then the crontab entry is simply:
> 47 4 * * * /root/backup.sh
The backup.sh is essentially:

rdiff-backup   \
  --print-statistics \
  --exclude /mnt \
  --exclude /dev \
  --exclude /proc \
  --exclude /tmp \
  --exclude /var/tmp \
  --exclude /var/cache/squid/ \
  --exclude /var/lib/mysql/ \
  --exclude /var/lib/postgresql/data/base/ \
  --exclude /var/lib/postgresql/data/global/ \
  --exclude /var/lib/postgresql/data/pg_clog/ \
  --exclude /var/lib/postgresql/data/pg_subtrans/ \
  --exclude /var/lib/postgresql/data/pg_tblspc/ \
  --exclude /var/lib/postgresql/data/pg_xlog/ \
  --exclude /sys \
  --exclude /usr/portage \
  --exclude /usr/portage/distfiles \
  --exclude /var/run \
 / backups@backuphost::/home/backups/hostname/
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 18:13   ` Ralph Slooten
  2007-11-04 18:50     ` Roger Mason
@ 2007-11-04 19:07     ` Neil Walker
  1 sibling, 0 replies; 16+ messages in thread
From: Neil Walker @ 2007-11-04 19:07 UTC (permalink / raw
  To: gentoo-user

Please, please, please do not top-post. :(


Be lucky,

Neil


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-03 20:36 [gentoo-user] rsync via ssh Roger Mason
  2007-11-04 15:24 ` Dirk Heinrichs
@ 2007-11-04 23:40 ` Shawn Haggett
  2007-11-05  0:43   ` Steve Dommett
  2007-11-05 11:04   ` Roger Mason
  1 sibling, 2 replies; 16+ messages in thread
From: Shawn Haggett @ 2007-11-04 23:40 UTC (permalink / raw
  To: gentoo-user

Roger Mason wrote:
> I have passwordless ssh between mymachine and backup_machine and the
> rsync command in the crontab runs perfectly from the command line.
> 
> Does someone know what else needs to be done to get this (seemingly
> simple!) task to work?
> 

How have you setup the passwordless ssh? If your using keys with the ssh 
keyagent, then when the command is run in cron it wouldn't know where to 
find your ssh-agent...

Shawn
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 23:40 ` Shawn Haggett
@ 2007-11-05  0:43   ` Steve Dommett
  2007-11-05 11:04   ` Roger Mason
  1 sibling, 0 replies; 16+ messages in thread
From: Steve Dommett @ 2007-11-05  0:43 UTC (permalink / raw
  To: gentoo-user

On Sunday 04 November 2007, Shawn Haggett wrote:
> Roger Mason wrote:
> How have you setup the passwordless ssh? If your using keys with the ssh
> keyagent, then when the command is run in cron it wouldn't know where to
> find your ssh-agent...
>
> Shawn

I use a use a key with no password without ssh-agent.
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-04 23:40 ` Shawn Haggett
  2007-11-05  0:43   ` Steve Dommett
@ 2007-11-05 11:04   ` Roger Mason
  2007-11-05 11:38     ` W.Kenworthy
  1 sibling, 1 reply; 16+ messages in thread
From: Roger Mason @ 2007-11-05 11:04 UTC (permalink / raw
  To: gentoo-user

Shawn Haggett <podge@podgeweb.com> writes:

> Roger Mason wrote:
>> I have passwordless ssh between mymachine and backup_machine and the
>> rsync command in the crontab runs perfectly from the command line.
>>
>> Does someone know what else needs to be done to get this (seemingly
>> simple!) task to work?
>>
>
> How have you setup the passwordless ssh? If your using keys with the
> ssh keyagent, then when the command is run in cron it wouldn't know
> where to find your ssh-agent...

Yes, I think that is the problem.  I'm going to try the technique
described here:

http://arctic.org/~dean/rdiff-backup/unattended.html

Will report back.

Cheers,
Roger
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh
  2007-11-05 11:04   ` Roger Mason
@ 2007-11-05 11:38     ` W.Kenworthy
  2007-11-05 12:17       ` [gentoo-user] rsync via ssh [solved] Roger Mason
  0 siblings, 1 reply; 16+ messages in thread
From: W.Kenworthy @ 2007-11-05 11:38 UTC (permalink / raw
  To: gentoo-user


On Mon, 2007-11-05 at 07:34 -0330, Roger Mason wrote:
> Shawn Haggett <podge@podgeweb.com> writes:
> 
> > Roger Mason wrote:
> >> I have passwordless ssh between mymachine and backup_machine and the
> >> rsync command in the crontab runs perfectly from the command line.
> >>
> >> Does someone know what else needs to be done to get this (seemingly
> >> simple!) task to work?
> >>
> >
> > How have you setup the passwordless ssh? If your using keys with the
> > ssh keyagent, then when the command is run in cron it wouldn't know
> > where to find your ssh-agent...
> 
> Yes, I think that is the problem.  I'm going to try the technique
> described here:
> 
> http://arctic.org/~dean/rdiff-backup/unattended.html
> 
> Will report back.
> 
> Cheers,
> Roger

Keep in mind that cron runs with a very limited environment for safety
reasons.  You have to manually set most env variables and the like.

BillK

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] rsync via ssh [solved]
  2007-11-05 11:38     ` W.Kenworthy
@ 2007-11-05 12:17       ` Roger Mason
  0 siblings, 0 replies; 16+ messages in thread
From: Roger Mason @ 2007-11-05 12:17 UTC (permalink / raw
  To: gentoo-user

"W.Kenworthy" <billk@iinet.net.au> writes:

>> > Roger Mason wrote:
>> >> I have passwordless ssh between mymachine and backup_machine and the
>> >> rsync command in the crontab runs perfectly from the command line.
>> >>
>> >> Does someone know what else needs to be done to get this (seemingly
>> >> simple!) task to work?

>> Yes, I think that is the problem.  I'm going to try the technique
>> described here:
>> 
>> http://arctic.org/~dean/rdiff-backup/unattended.html
>> 
>
> Keep in mind that cron runs with a very limited environment for safety
> reasons.  You have to manually set most env variables and the like.

Yes.  I finally have it working using the technique described in the
above URL.  

Thanks to all who responded.

Roger
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-11-05 12:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-03 20:36 [gentoo-user] rsync via ssh Roger Mason
2007-11-04 15:24 ` Dirk Heinrichs
2007-11-04 18:44   ` Roger Mason
2007-11-04 23:40 ` Shawn Haggett
2007-11-05  0:43   ` Steve Dommett
2007-11-05 11:04   ` Roger Mason
2007-11-05 11:38     ` W.Kenworthy
2007-11-05 12:17       ` [gentoo-user] rsync via ssh [solved] Roger Mason
  -- strict thread matches above, loose matches on Subject: below --
2007-11-03 21:06 [gentoo-user] rsync via ssh Richard Ruth
2007-11-04 14:54 ` Roger Mason
2007-11-04 17:59   ` Steve Dommett
2007-11-04 18:46     ` Roger Mason
2007-11-04 19:04       ` Steve Dommett
2007-11-04 18:13   ` Ralph Slooten
2007-11-04 18:50     ` Roger Mason
2007-11-04 19:07     ` Neil Walker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox