template-backup-script.sh.in 938 Bytes
Newer Older
1 2 3 4 5 6
#!${dash-output:dash}

# trap "echo Backing up failed for $${:hostname}" ERR

export HOME=$${directory:home}

7 8 9 10 11 12 13
# Clean status file (no history needed)
${coreutils-output:rm} -f $${:status_log}

# Inform about beginning of backup
${coreutils-output:echo} "`${coreutils-output:date} -u`, $${:hostname} backup running" >> $${:status_log}

# set -e
14 15 16 17 18 19 20 21
cd $${:datadirectory}
${rdiff-backup-output:rdiff-backup} \
  $${:exclude_string} \
  --include='$${:include}' \
  --exclude='**' \
  --remote-schema '${dropbear-output:ssh} -T -y -i $${:sshkey} %s $${:remote_schema}' \
  $${:connection}::/ ./

22 23 24 25 26 27 28 29 30 31
RESULT=$?
 
# Inform about backup status
if [ $RESULT == 0 ]
then
  ${coreutils-output:echo} "`${coreutils-output:date} -u`, $${:hostname} backup success" >> $${:status_log}
else
  ${coreutils-output:echo} "`${coreutils-output:date} -u`, $${:hostname} backup failed" >> $${:status_log}
fi

32 33
# python scripts/verify_with_sudo.py ./ $${:connection}:/