Last active
December 14, 2015 04:19
-
-
Save rsdy/5027329 to your computer and use it in GitHub Desktop.
simple backup script wrapping tarsnap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh | |
# | |
# compile tarsnap, and install it to $BASEDIR | |
# | |
# put the files/dirs to be included into $BASEDIR/includes | |
# specify exclude patterns in $BASEDIR/excludes | |
# both files should contain either space or newline-separated items | |
# | |
# tweak $DELETE_ARCH to specify the retention time after which the | |
# archives will be deleted | |
# | |
# deletion of archives is lazy, only one at a time. i do consider | |
# this a feature | |
# | |
PATH="${BASEDIR}/bin:${PATH}" | |
HOST="$(hostname)" | |
BASEDIR="/root/tarsnap" | |
EXCLUDE_FILE="excludes" | |
INCLUDE_FILE="includes" | |
DATE_TEMPLATE='date +%Y%m%d' | |
ARCH_NAME="${HOST}-$(${DATE_TEMPLATE})" | |
DELETE_ARCH="${HOST}-$(${DATE_TEMPLATE} --date='5 days ago')" | |
tarsnap --configfile ${BASEDIR}/etc/tarsnap.conf -cf "$ARCH_NAME" \ | |
--one-file-system \ | |
$(sed 's/\(^\| \)/ --exclude /g' ${BASEDIR}/${EXCLUDE_FILE}) \ | |
$(cat ${BASEDIR}/${INCLUDE_FILE}) \ | |
&>${BASEDIR}/log/${ARCH_NAME} | |
tarsnap --configfile ${BASEDIR}/etc/tarsnap.conf -df $DELETE_ARCH \ | |
&>>${BASEDIR}/log/${ARCH_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment