From: MegaBrutal Date: Wed, 2 Sep 2015 20:32:55 +0000 (+0200) Subject: backup_diff.sh, backup_full.sh: Cleaned up for publication, added rsync transfer... X-Git-Url: http://git.megabrutal.com/?a=commitdiff_plain;h=51b282d82d08b095a3826d44e444464bd2eeaf0a;p=mgsautils.git backup_diff.sh, backup_full.sh: Cleaned up for publication, added rsync transfer mode - Moved hard-coded data to separate config file. - Now it is configurable how to transfer backup files to a remote server: it is possible by scp or rsync, or to not transfer them at all. The backup directory may be mounted from a remote server by NFS or other method, in which case there is no need to transfer the files by scp or rsync. Note however, backup_full.sh purges the backup directory, because it is assumed that the files have already been transferred to a remote location. modified: fs/backup_diff.sh new file: fs/backup_fsdiff.conf modified: fs/backup_full.sh --- diff --git a/fs/backup_diff.sh b/fs/backup_diff.sh old mode 100644 new mode 100755 index 404b5e3..01145bd --- a/fs/backup_diff.sh +++ b/fs/backup_diff.sh @@ -1,4 +1,15 @@ -# PLACEHOLDER FILE! -# This script is not yet ready for publication, as it contains environment-specific and/or hard-coded sensitive data. -# This file is here to annoy myself to make an update. -# ~ MegaBrutal +#!/bin/sh +. $1 +FILENAME=${DIFFNAME}${APPEND} +cd ${STORAGE} +dar --verbose --alter=atime --empty-dir --fs-root / --noconf --create ${STORAGE}${FILENAME} --ref $(ls --sort=t ${STORAGE}*.dar | head -n 1 | cut -d. -f1) -y9 -an --exclude-from-file ${EXCLUDE} +md5sum -b *.dar > $(ls --sort=t ${FULLNAME}*.md5 | head -n 1) + +case "${XFER_METHOD}" in + scp) + su - ${XFER_USER} -c "scp -p ${STORAGE}${FILENAME}* $(ls --sort=t ${STORAGE}${FULLNAME}*.md5 | head -n 1) ${XFER_TARGET}" + ;; + rsync) + su - ${XFER_USER} -c "rsync -auv ${STORAGE} ${XFER_TARGET}" + ;; +esac diff --git a/fs/backup_fsdiff.conf b/fs/backup_fsdiff.conf new file mode 100644 index 0000000..3a3da89 --- /dev/null +++ b/fs/backup_fsdiff.conf @@ -0,0 +1,9 @@ +FULLNAME=filesys_$(hostname -s)_full +DIFFNAME=filesys_$(hostname -s)_diff +APPEND=$(date +%Y%m%d) +STORAGE=/var/backups/fs/data/ +EXCLUDE=/var/backups/fs/exclude.lst + +XFER_METHOD=scp +XFER_USER=backup +XFER_TARGET= diff --git a/fs/backup_full.sh b/fs/backup_full.sh old mode 100644 new mode 100755 index 404b5e3..2967c12 --- a/fs/backup_full.sh +++ b/fs/backup_full.sh @@ -1,4 +1,17 @@ -# PLACEHOLDER FILE! -# This script is not yet ready for publication, as it contains environment-specific and/or hard-coded sensitive data. -# This file is here to annoy myself to make an update. -# ~ MegaBrutal +#!/bin/sh +. $1 +FILENAME=${FULLNAME}${APPEND} +cd ${STORAGE} +rm * +dar --verbose --alter=atime --empty-dir --fs-root / --noconf --create ${STORAGE}${FILENAME} -y9 -an --exclude-from-file ${EXCLUDE} +md5sum -b ${FILENAME}* > ${FILENAME}.md5 +chown ${XFER_USER} ${FILENAME}.md5 + +case "${XFER_METHOD}" in + scp) + su - ${XFER_USER} -c "scp -p ${STORAGE}${FILENAME}* ${XFER_TARGET}" + ;; + rsync) + su - ${XFER_USER} -c "rsync -auv ${STORAGE} ${XFER_TARGET}" + ;; +esac