]> git.sesse.net Git - backup.sh/blobdiff - skruebackup.sh
skruebackup is no longer in use
[backup.sh] / skruebackup.sh
diff --git a/skruebackup.sh b/skruebackup.sh
deleted file mode 100755 (executable)
index b7a4445..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-#! /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};
-