From ff16c056c6afd92eb4f0dfa08cf915da532c495c Mon Sep 17 00:00:00 2001 From: root Date: Sun, 12 Oct 2014 15:32:43 +0200 Subject: [PATCH] skruebackup is no longer in use --- backup.sh | 14 +++++- skruebackup.sh | 123 ------------------------------------------------- 2 files changed, 13 insertions(+), 124 deletions(-) delete mode 100755 skruebackup.sh diff --git a/backup.sh b/backup.sh index 7fc7ffb..cfac607 100755 --- a/backup.sh +++ b/backup.sh @@ -107,6 +107,16 @@ backup() 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 @@ -119,7 +129,7 @@ backup() # 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 @@ -161,6 +171,8 @@ backup() # - 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" diff --git a/skruebackup.sh b/skruebackup.sh deleted file mode 100755 index b7a4445..0000000 --- a/skruebackup.sh +++ /dev/null @@ -1,123 +0,0 @@ -#! /bin/bash - -### About -# Written by Stein Magnus Jodal -# 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}; - -- 2.39.2