lastcmd="--listed-incremental=$remotesnar"
fi
+ # The file is usually stored to disk with a simple cat > $TARFILE,
+ # but in some cases, like backing up to a remote and untrusted
+ # file system, it could be useful to replace it with e.g.
+ # a GPG command line.
+ if [ -f $confdir/storageprogram.$computer ]; then
+ storageprogram=`cat $confdir/storageprogram.$computer`
+ else
+ storageprogram=cat
+ fi
+
# We try to run tar on the remote computer
# c create archive
# C change to directory first
# file and build a file list, respectivly.
TARFILE=$DATE.tmp
TARCMD="ssh -n $username@$computer \"nice -n 19 ionice -c3 tar --one-file-system --use-compress-program $compressor -cf - -C $filesystem . $lastcmd \
- --exclude-from=$remotehome/.backup/exclude\" | pee \"cat > $TARFILE\" \"tar tzvf -\""
+ --exclude-from=$remotehome/.backup/exclude\" | pee \"$storageprogram > $TARFILE\" \"tar tzvf -\""
infomsg "Running $TARCMD"
eval $TARCMD > $DATE.idx
# - No touching of .lastbackup for Nagios.
# - Failed tar operations may go undetected, since we only see the error code
# the last process in the pipe chain, which is gpg.
+# - No storageprogram support (see above), because the file is typically already
+# encrypted.
nonprivbackup()
{
infomsg "$computer:$filesystem $backuplevel non-privileged backup"
+++ /dev/null
-#! /bin/bash
-
-### About
-# Written by Stein Magnus Jodal <stein.magnus@jodal.no>
-# Distributed under the GNU General Public License version 2.
-
-### ChangeLog
-# 2003-10-20 Stein Magnus Jodal
-# - Started, but I was too tired and went home.
-#
-# 2003-10-22 Stein Magnus Jodal
-# - Continued, but I started to chat instead.
-#
-# 2003-10-27 Stein Magnus Jodal
-# - The script started looking like something usefull.
-#
-# 2003-11-10 Stein Magnus Jodal
-# - The script can now delete old archives!
-#
-# 2004-10-17 Stein Magnus Jodal
-# - The script now creates the storagedirs if they don't exists.
-# - The delete old archives part doesn't fail if we don't have any old archives
-# anymore. (shopt -s nullglob, so the script now requires bash)
-# - Fixed s/:/;/ at one of the lines. This made the first backup run use
-# "full:" instead of "full" as target dir.
-#
-# 2004-10-18 Stein Magnus Jodal
-# - Fixed the calculation of $LIMIT and added a new check under the deletion
-# part
-
-### Usage
-# skruebackup.sh -full
-# Run full backup
-#
-# skruebackup.sh -incr
-# Run incremental backup (default if the lastrun file exists)
-#
-# Example for crontab usage:
-# 0 4 1 * * /path/to/skruebackup.sh -full
-# 0 6 * * * /path/to/skruebackup.sh -incr
-
-### Vars
-# Number of archives to keep
-NUMFULL=3 # months (31 days)
-NUMINCR=40 # days
-# Dir to store the backups to
-STORAGEDIR="/backup/skrue";
-# File listing what dirs to backup
-BACKUPLIST="/home/backup/skruebackup_this.txt";
-# File touched for every backup
-LASTRUNFILE="${STORAGEDIR}/skruebackup_lastrun";
-# Programs
-SMBTAR="/usr/bin/smbtar -s skrue -x tilkolje -u skruebackup -p 'gl25bE!v' -t -";
-GZIP="/bin/gzip -6";
-# Dates
-TODAY=$(date +%Y-%m-%d);
-TODAY_EPOCH=$(date +%s);
-
-### DON'T EDIT ANYTHING BELOW THIS LINE ###
-
-# If we got empty dirs, we don't want dir/* to be passed on
-shopt -s nullglob
-
-### Create dirs
-if [ ! -d ${STORAGEDIR} ]; then
- echo "--- Creating backup dir";
- mkdir -vp ${STORAGEDIR}/full ${STORAGEDIR}/incr;
-fi
-
-### Delete old archives
-echo "--- Deleting old archives";
-
-# Deleting old full archives
-LIMIT=$(( ${TODAY_EPOCH} - ${NUMFULL} * 31 * 24 * 60 * 60 ));
-
-for FILE in ${STORAGEDIR}/full/*; do
- if [ -e ${FILE} ]; then
- THIS_DATE=$(echo ${FILE} | sed 's/^.*_//; s/\.tar\.gz$//');
- THIS_EPOCH=$(date --date="${THIS_DATE}" +%s);
- if [ "${THIS_EPOCH}" -lt "${LIMIT}" ]; then
- rm -v ${FILE};
- fi
- fi
-done
-
-# Delete old incremental archives
-LIMIT=$(( ${TODAY_EPOCH} - ${NUMINCR} * 24 * 60 * 60 ));
-
-for FILE in ${STORAGEDIR}/incr/*; do
- if [ -e ${FILE} ]; then
- THIS_DATE=$(echo ${FILE} | sed 's/^.*_//; s/\.tar\.gz$//');
- THIS_EPOCH=$(date --date="${THIS_DATE}" +%s);
- if [ "${THIS_EPOCH}" -lt "${LIMIT}" ]; then
- rm -v ${FILE};
- fi
- fi
-done
-
-### Full or incremental backup
-if [ "$1" = "-full" ]; then
- echo "--- Running full backup";
- STORAGEDIR="${STORAGEDIR}/full";
-else
- if [ -w ${STORAGEDIR}/skruebackup_lastrun ]; then
- echo "--- Running incremental backup";
- STORAGEDIR="${STORAGEDIR}/incr";
- SMBTAR="${SMBTAR} -N ${LASTRUNFILE} -i";
- else
- echo "--- Running full backup";
- STORAGEDIR="${STORAGEDIR}/full";
- fi
-fi
-
-# The actual backup
-for DIR in $(cat ${BACKUPLIST}); do
- echo ">>> Currently processing ${DIR}";
- ${SMBTAR} -d ${DIR} | ${GZIP} > ${STORAGEDIR}/skruebackup_${DIR}_${TODAY}.tar.gz;
-done
-
-### Updating last runned record
-echo "--- Updating last runned record";
-touch ${LASTRUNFILE};
-