From: MegaBrutal Date: Tue, 29 Sep 2015 03:22:36 +0000 (+0200) Subject: backup_diff.sh, backup_full.sh: Prepared for in-place backups X-Git-Url: http://git.megabrutal.com/?a=commitdiff_plain;h=fff3adbec4d94fade954a352ef076b5bbd97ea32;p=mgsautils.git backup_diff.sh, backup_full.sh: Prepared for in-place backups - Added option CLEAN_DIR to backup_fsdiff.conf which enables/disables purging of the backup directory whenever a new full backup is made. Previously, the hard-coded behavior was to purge the $STORAGE directory. - MD5 checksum is now only counted for the recently made backup file. Previously, all checksums were recalculated. Now it is possible to have the main backup repository mounted at $STORAGE and keep several weeks (or whatever backup cycle you have) of backups there. With previous versions of the script, you were supposed to transfer those files to a remote server, while the local $STORAGE directory was only used as temporary storage. Now you can even mount $STORAGE directly from the remote server through NFS or iSCSI, if that is more convenient for you. modified: backup_diff.sh modified: backup_fsdiff.conf modified: backup_full.sh --- diff --git a/fs/backup_diff.sh b/fs/backup_diff.sh index 01145bd..56cc4ac 100755 --- a/fs/backup_diff.sh +++ b/fs/backup_diff.sh @@ -3,7 +3,7 @@ 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) +md5sum -b ${FILENAME}*.dar >> $(ls --sort=t ${FULLNAME}*.md5 | head -n 1) case "${XFER_METHOD}" in scp) diff --git a/fs/backup_fsdiff.conf b/fs/backup_fsdiff.conf index 3a3da89..632f794 100644 --- a/fs/backup_fsdiff.conf +++ b/fs/backup_fsdiff.conf @@ -3,6 +3,7 @@ DIFFNAME=filesys_$(hostname -s)_diff APPEND=$(date +%Y%m%d) STORAGE=/var/backups/fs/data/ EXCLUDE=/var/backups/fs/exclude.lst +CLEAN_DIR=false XFER_METHOD=scp XFER_USER=backup diff --git a/fs/backup_full.sh b/fs/backup_full.sh index 2967c12..4e828e6 100755 --- a/fs/backup_full.sh +++ b/fs/backup_full.sh @@ -2,7 +2,7 @@ . $1 FILENAME=${FULLNAME}${APPEND} cd ${STORAGE} -rm * +if [ "${CLEAN_DIR}" = "true" ]; then rm *; fi 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