Gentoo Archives: gentoo-user

From: Ralph Slooten <axllent@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] rsync via ssh
Date: Sun, 04 Nov 2007 18:20:13
Message-Id: 472E0BE7.90903@gmail.com
In Reply to: Re: [gentoo-user] rsync via ssh by Roger Mason
1 I have done a similar thing at work, except what I do is first create an
2 ssh tunnel, then rsync to the locally listening port. Works perfectly.
3 In my setup the remote server is running an SSH server which is not
4 accessible directly. Maybe this will help you.
5
6
7 #!/bin/bash
8 SSL_COMMAND="ssh -p 2222 sshuser@myserver -f -N -L 8000:localhost:873"
9 SSL_PID=`ps aux | grep "$SSL_COMMAND" | egrep -v 'grep' | awk '{print $2}'`
10
11 if [ "$SSL_PID" == "" ]; then
12 echo "=> Creating SSH tunnel to myserver"
13 $SSL_COMMAND
14 SSL_PID=`ps aux | grep "$SSL_COMMAND" | egrep -v 'grep' | awk
15 '{print $2}'`
16 else
17 echo "=> SSH tunnel already exists. Using existing tunnel."
18 fi
19
20 if [ "$SSL_PID" != "" ]; then
21 echo "=> Connecting through SSH tunnel with PID $SSL_PID"
22 rsync rsync://localhost:8000/wwwroot
23 /mnt/samba/hotcopy/myserver/wwwroot \
24 -rvtzp --delete --modify-window=1
25
26 echo "=> Closing SSH tunnel"
27 kill $SSL_PID
28 else
29 echo "ERROR: SSH Connection failed! The backup could not complete"
30 fi
31
32
33
34 Cheers,
35 Ralph
36
37 Roger Mason wrote:
38 > Hi Richard,
39 >
40 > Richard Ruth <richgentoo@×××××××.net> writes:
41 >
42 >> Try adding "-e ssh" to your rsync command.
43 >> Search for "-e" in the rsync man page for an example.
44 >> =======================
45 >> This is the crontab entry (in rmason's crontab):
46 >> 0,15,30,45 * * * * rmason /usr/bin/rsync -av /home/rmason backup_machine:my
47 >> machine_rmason
48 >
49 > Thanks for the reply. Unfortunately that did not work, the same error
50 > ocurs.
51 >
52 > This is what I have currently:
53 > 0,15,30,45 * * * * /usr/bin/rsync -av -e "ssh" /home/rmason rmason@backup_machine:mymachine_rmason
54 >
55 > I've tried with and without the quotes plus with and without the
56 > rmason@ but none worked.
57 >
58 > I think I'll try scp and see what happens.
59 >
60 > Cheers,
61 > Roger
62 --
63 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] rsync via ssh Roger Mason <rmason@×××××××.ca>
Re: [gentoo-user] rsync via ssh Neil Walker <neil@×××××××.nu>