DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-10-12 03:25:18

iana
New member
Registered: 2008-10-12
Posts: 2

Making backups of a remote machine

Hi, I've been trying to solve a backup problem with my DNS323 and a couple of laptops (OSX & linux).

What I want to do is very similar to http://dns323.kood.org/forum/t2125-DNS- … hine!.html but the source for the backups is a remote machine. I want to save space using the rsync/hard-link trick, but this means I have to run rsync on the DNS-323 (because of hardlinks not working across file-system boundaries). This means I have to do it using rsync over ssh.

At the moment I have to ssh into the DNS323 then run the shell script which will then ask for the password of he machine being backed up. The obvious solution would be using ssh-keys, but the agent doesn't seem to work (see http://forum.source.pri.ee/t1838-sftp.html). I've tried writing an expect script, but it fails because I can't make interactive commands run over ssh

Below is my script so far. It works if I ssh into the DNS-323 and run it as ./backupscript.sh (it will prompt me for the password of the target machine then start running), but if I try to do it from the target machine e.g.

ssh user1@DNS323 "./backupscrip.sh"

then I don't get prompted for the password that rsync needs, and the whole thing fails.

Does anyone have a solution to this (or even a better way of doing it).


#! /ffp/bin/bash

unset PATH

# The directory to be backed up on remote laptop
BACKUPDIR=/home/user1
SNAPSHOT_HOST=user1@192.168.X.XX
SNAPSHOT_DIR=/mnt/HD_b2/backups/machine1
EXCLUDES=/mnt/HD_b2/backups/machine1/backup-excludes
BACKUPDEPTH=5

ECHO=/ffp/bin/echo
RM=/ffp/bin/rm
MV=/ffp/bin/mv
CP=/ffp/bin/cp
TOUCH=/ffp/bin/touch
RSYNC=/ffp/bin/rsync
SSH=/ffp/bin/ssh


$RSYNC -va -e $SSH --delete --delete-excluded --exclude-from="$EXCLUDES" \
    --link-dest=$SNAPSHOT_DIR/backup.0 \
    $SNAPSHOT_HOST:$BACKUPDIR/ $SNAPSHOT_DIR/backup.tmp

if (( $? )); then
    $ECHO "Error creating the backup!"
    exit
fi

#
#OK, The backup was successful, now start shuffling
#
# Remove the oldest snapshot
if [ -d $SNAPSHOT_DIR/backup.$BACKUPDEPTH ] ; then
    $RM -rf $SNAPSHOT_DIR/backup.$BACKUPDEPTH
fi

# Rotate the rest of the old backups
while [ $BACKUPDEPTH -gt 0 ] ; do

    OLDBACKUPD=$BACKUPDEPTH
    BACKUPDEPTH=$(($BACKUPDEPTH - 1))   

    if [ -d $SNAPSHOT_DIR/backup.$BACKUPDEPTH ] ; then

           echo "Rotating $OLDBACKUPD into $BACKUPDEPTH"

           $MV $SNAPSHOT_DIR/backup.$BACKUPDEPTH \
                  $SNAPSHOT_DIR/backup.$OLDBACKUPD
    fi

done

$MV $SNAPSHOT_DIR/backup.tmp $SNAPSHOT_DIR/backup.0

Offline

 

#2 2008-10-15 19:47:44

blbrown
Member
Registered: 2007-11-02
Posts: 88
Website

Re: Making backups of a remote machine

You might take a look at BackupNetClone (http://backupnetclone.sourceforge.net/).  It will take some effort on your part to install it, but it might be just what you're looking for.

Offline

 

#3 2008-10-16 06:01:46

iana
New member
Registered: 2008-10-12
Posts: 2

Re: Making backups of a remote machine

Thanks, I didn't know about that project. I think it does exactly what I have been trying to do. I'll dig around in their code and see if I can find what I need.

Ian.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB