Subject: Re: Software for off-site backups
To: None <netbsd-users@NetBSD.org>
From: Peter Eisch <peter@boku.net>
List: netbsd-users
Date: 11/17/2007 09:09:34
On 11/17/07 8:59 AM, "Geert Hendrickx" <ghen@telenet.be> wrote:
> ... 
> Have you considered dump/restore?  ...
> 

If you create a user, USER on a remote system SYSTEM with ssh access (using
authorized_keys) and create two directories "Config" and "OS" this is my
swiss army knife.  It could likely be adapted to suit your needs...?

# cat /etc/daily.local

REM_USER=USER
REM_HOST=SYSTEM

export REM_USER REM_HOST

DOA=`date +%w`
export DOA

echo "backing up backups to: ${REM_USER}@${REM_HOST}:Config/${DOA}"
/usr/bin/ssh ${REM_USER}@${REM_HOST} "/bin/rm -rf Config/${DOA}/backups"
/usr/bin/scp -rp /var/backups ${REM_USER}@${REM_HOST}:Config/${DOA}

if [ $? -eq 0 ]; then
  echo "...done"
fi

DUMP_ARGS="9uf"
KEY=`/bin/hostname | sum | awk '{print $1 % 7}'`
DAY=`date +%u`
if [ "$DAY" -eq "$KEY" ]; then
  DUMP_ARGS="0uf"
fi

for fs in `/usr/bin/grep ffs /etc/fstab | /usr/bin/awk -F/ '{print $3}'`
do
 echo "backing up ${fs}..."
 /usr/bin/ssh ${REM_USER}@${REM_HOST} "/bin/mv -vf OS/$fs.$DAY.dump \
OS/$fs.$DAY.old"
 /sbin/dump $DUMP_ARGS - /dev/${fs}  | ( /usr/bin/ssh
${REM_USER}@${REM_HOST} "cat > OS/$fs.$DAY.dump" )
 if [ $? -eq 0 ]; then
   echo "done"
 fi
done

# end of /etc/daily.local