#!/bin/sh
# Osamu's simple backup script for home Linux user.  (Version 2)
#   Feature: multiple cd, data redundancy
#   License: GPL 2.0 or later.
#   Depends: afio ras gzip cdrecord mkisofs sudo
#   Author:  Osamu Aoki <osamu@debian.org>
#
# Place "afiocd" and this script in your path as executable.
# "afiocd" is also located in Debian Reference examples.
# "afiocd" is a generic part of cd backup script.
# This can backup to multiple cds with redundancies to handle 
# larger tasks.
#
# These are still very alpha stage script.  Use this only as an example.
# Use at your own risk and read script and its comment in advance.

DATE=$(date --utc +"%Y%m%d-%H%M")
[ -d /var/backups ] || mkdir -p /var/backups

# Make package selection backed up
sudo dpkg --get-selections \*  >/var/backups/dpkg-selections.${DATE}.log

# define files to back up and feed their names to the stdin of afiocd
sudo find /etc /home /var/lib/dpkg /var/backups /var/lib/cvs \
     -xdev \
     -path '*/Cache' -prune -o \
     -path '*/Mail' -prune -o \
     -path '*/public_html' -prune -o \
     -print0 | afiocd
sudo touch /last-backup.stamp

# You may edit above to do incremental backup.
# use touch to create a file after back up
# use "-cnewer /last-backup.stamp" to narrow down back up.
