BackupPC-users

[BackupPC-users] rsyncd via ssh-redirected port

2009-12-19 08:01:02
Subject: [BackupPC-users] rsyncd via ssh-redirected port
From: Guido Schmidt <gs AT schalloch DOT de>
To: backuppc-users AT lists.sourceforge DOT net
Date: Sat, 19 Dec 2009 13:21:08 +0100
Dear backuppc-users,

I'm happily using BackupPC 3.1.0 for quite a while.

I'm now trying to backup a public host (host.example.com) via an ssh-redirected 
port. I don't allow any command execution on that host (and therefore cannot 
use the wait command), so I wrote a script (sshtunnelcontrol, see below) to 
open and close the tunnel when needed. It is called as DumpPreUserCmd and 
DumpPostUserCmd. 

What works? The opening and closing of the tunnel.
What does not? The connection to it. Nothing in the rsyncd-logs on 
host.example.com.

If I leave DumpPostUserCmd empty the tunnel stays open and I can use it with 
rsync as user backuppc on a shell providing the password by hand:

  rsync -av --list-only --port=32323 backuppc@localhost::Alles 
/home/backuppc/test/


XferMethod is rsyncd.
RsyncdClientPort is set to 873.

I double-checked the password in /etc/BackupPC/pc/host.example.com.pl.

Running

  /usr/local/BackupPC/bin/BackupPC_dump -v -f host.example.com

didn't give more information.


Thank you for any hint.
Guido



--- Begin of file /local/backup/pc/host.example.com/XferLOG.bad.z, modified 
2009-12-17 19:50:13 ---

Executing DumpPreUserCmd: /usr/local/bin/sshtunnelcontrol start 
host.example.com /usr/bin/ssh -CN 32323 localhost 873 backuppc 43868
SSH Tunnel Control: Opening tunnel
SSH Tunnel Control: /usr/bin/ssh -CN -L 32323:localhost:873 -l backuppc -p 
43868 host.example.com &
SSH Tunnel Control: Process ID is 24538
SSH Tunnel Control: Created /home/backuppc/sshtunnel-host.example.com.pid
SSH Tunnel Control: Checking for tunnel:
backuppc 24538 24537  0 19:50 ?        00:00:00 /usr/bin/ssh -CN -L 
32323:localhost:873 -l backuppc -p 43868 host.example.com
incr backup started back to 2009-11-24 15:50:34 (backup #0) for directory Alles
Error connecting to rsync daemon at localhost:32323: inet connect: 
Verbindungsaufbau abgelehnt
Executing DumpPostUserCmd: /usr/local/bin/sshtunnelcontrol stop host.example.com
SSH Tunnel Control: Killing Process 24538
SSH Tunnel Control: Done
SSH Tunnel Control: Deleting /home/backuppc/sshtunnel-host.example.com.pid
SSH Tunnel Control: Done
Got fatal error during xfer (inet connect: Verbindungsaufbau abgelehnt)
Backup aborted (inet connect: Verbindungsaufbau abgelehnt)

--- End of file /local/backup/pc/host.example.com/XferLOG.bad.z, modified 
2009-12-17 19:50:13 ---



-------- Begin /etc/BackupPC/pc/host.example.com.pl ----------

$Conf{PingMaxMsec} = 400;
$Conf{RsyncArgs} = [
  '--numeric-ids',
  '--perms',
  '--owner',
  '--group',
  '-D',
  '--links',
  '--hard-links',
  '--times',
  '--block-size=2048',
  '--recursive',
  '--checksum-seed=32761'
];
$Conf{RsyncShareName} = [
  'Alles'
];
$Conf{XferLogLevel} = 3;
$Conf{XferMethod} = 'rsyncd';
$Conf{RsyncdUserName} = 'backuppc';
$Conf{DumpPreUserCmd} = '/usr/local/bin/sshtunnelcontrol start $client $sshPath 
-CN 32323 $host 873 backuppc 12345';
$Conf{DumpPostUserCmd} = '/usr/local/bin/sshtunnelcontrol stop $client';
$Conf{RsyncdClientPort} = 32323;
$Conf{ClientNameAlias} = 'localhost';
$Conf{RsyncdPasswd} = '********************';
$Conf{UserCmdCheckStatus} = '1';
$Conf{PingCmd} = '$pingPath -c 1 -w 3 host.example.com';

-------- End /etc/BackupPC/pc/host.example.com.pl ----------



-------- Begin /usr/local/bin/sshtunnelcontrol ----------
#!/bin/sh
TODO=$1
CLIENT=$2
SSH_PATH=$3
SSH_OPTS=$4
SSH_TUNNEL_PORT=$5
SSH_HOST=$6
RSYNC_PORT=$7
SSH_USER=$8
SSH_PORT=$9

PRG_NAME="SSH Tunnel Control"
BASEDIR=/home/backuppc
PIDFILE="${BASEDIR}/sshtunnel-${CLIENT}.pid"

case "$TODO" in
  start)
    if [ ! -e "${PIDFILE}" ]; then
      echo "$PRG_NAME: Opening tunnel"
      echo "$PRG_NAME: $SSH_PATH $SSH_OPTS -L 
$SSH_TUNNEL_PORT:$SSH_HOST:$RSYNC_PORT -l $SSH_USER -p $SSH_PORT $CLIENT &"
      $SSH_PATH $SSH_OPTS -L $SSH_TUNNEL_PORT:$SSH_HOST:$RSYNC_PORT -l 
$SSH_USER -p $SSH_PORT $CLIENT 1>/dev/null 2>/dev/null &
      #$SSH_PATH $SSH_OPTS -L $SSH_TUNNEL_PORT:$SSH_HOST:$RSYNC_PORT -l 
$SSH_USER -p $SSH_PORT $CLIENT &
      PID=$!
      echo "$PRG_NAME: Process ID is $PID"
      echo $PID > "${PIDFILE}" &&  echo "$PRG_NAME: Created ${PIDFILE}"
      echo "$PRG_NAME: Checking for tunnel:"
      if ! ps -ef|grep -E "^backuppc $PID" ; then
        echo "$PRG_NAME: Error: Tunnel does not exist"
        exit 1
      fi
    else
      echo "$PRG_NAME: Error: ${PIDFILE} already exists."
      exit 2
    fi
    ;;
  stop)
    if [ ! -e "${PIDFILE}" ]; then
      echo "$PRG_NAME: Error: Can not find process. $PIDFILE is missing."
      exit 3
    else
      PID2KILL=`cat ${PIDFILE}`
      echo "$PRG_NAME: Killing Process $PID2KILL"
      kill -15 $PID2KILL && echo "$PRG_NAME: Done"
      echo "$PRG_NAME: Deleting $PIDFILE"
      rm $PIDFILE && echo "$PRG_NAME: Done"
    fi
    ;;
  *)
      echo "$PRG_NAME: Parameter-error"
      exit 4
      ;;
esac
-------- End /usr/local/bin/sshtunnelcontrol ----------




------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/