#!/bin/bash
# paul@vandervlis.nl
# backup client to server

# Local DIR voor backup
LDIR="/backup/client8"
# What to exclude from backup
EXCLUDE="\
--exclude=/mnt/** \
--exclude=/backup/** \
--exclude=/proc/** \
--exclude=/tmp/** \
--exclude=/lost+found \
--exclude=/sys/** \
--exclude=/var/cache/apt/archives/** \
--exclude=/home/** \
--exclude=/data/** \
"

# ask machinename when not on commandline:
if test "$1" = ""; then
  read -p "Machine name (example: mm-n001): " machine
else
  machine=$1
fi
if test "$machine" = ""; then
  echo no machine.
  exit
fi

#sync to server
echo -e "\n`date +%T` Sync to backup-server:"
if ! test -e $LDIR; then mkdir -p $LDIR; chmod 700 $LDIR; fi
cd $LDIR
nice rsync -axzve ssh --numeric-ids --del --delete-excluded  $EXCLUDE \
   $machine:/ ./
echo -e "\n`date +%T` Finished."
echo
