#!/bin/sh # -*- shell-script -*- # Time-stamp: <2012-01-16 20:59:54 rsmith> # # This should be: /usr/local/sbin/backup-local # Back up local filesystems from ada0 to ada1 on Slackbox. # # Author: R.F. Smith # Time-stamp: <2008-07-30 23:43:28 rsmith> # # To the extent possible under law, Roland Smith has waived all copyright and # related or neighboring rights to backup-local. This work is published from the # Netherlands. See http://creativecommons.org/publicdomain/zero/1.0/ # Check for non-standard programs that are used in this script. PROGS="rsync" for P in $PROGS; do which $P >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "$(basename $0): The program \"$P\" cannot be found." exit 1 fi done FLAGS="-axq -H --delete --force-change" LOG="logger -t 'backup-local'" # This script assumes that the backups are not mounted. mount /mnt/bk/root if df|grep /mnt/bk/root >/dev/null; then #echo "/ is good to go!" rsync $FLAGS / /mnt/bk/root && $LOG "/ successfully backed-up." umount /mnt/bk/root else echo "Backup for / not mounted! Not backed up." fi mount /mnt/bk/usr if df|grep /mnt/bk/usr >/dev/null; then #echo "/usr is good to go!" # Trailing slash after source is important! See rsync(1). rsync $FLAGS /usr/ /mnt/bk/usr && $LOG "/usr successfully backed-up." umount /mnt/bk/usr else echo "Backup for /usr not mounted! Not backed up." fi mount /mnt/bk/home if df|grep /mnt/bk/home >/dev/null; then #echo "/home is good to go!" rsync $FLAGS /home/ /mnt/bk/home && $LOG "/home successfully backed-up." umount /mnt/bk/home else echo "Backup for /home not mounted! Not backed up." fi mount /mnt/bk/var if df|grep /mnt/bk/var >/dev/null; then #echo "/var is good to go!" rsync $FLAGS /var/ /mnt/bk/var && $LOG "/var successfully backed-up." umount /mnt/bk/var else echo "Backup for /var not mounted! Not backed up." fi