backup_diff.sh, backup_full.sh: Prepared for in-place backups
authorMegaBrutal <code+git@megabrutal.com>
Tue, 29 Sep 2015 03:22:36 +0000 (05:22 +0200)
committerMegaBrutal <code+git@megabrutal.com>
Tue, 29 Sep 2015 03:22:36 +0000 (05:22 +0200)
- 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

fs/backup_diff.sh
fs/backup_fsdiff.conf
fs/backup_full.sh

index 01145bd52363abbcecf4fcae8f6b3cfe2374bbd7..56cc4acfb00237dd66c43082332fff0c01025d63 100755 (executable)
@@ -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}
 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)
 
 case "${XFER_METHOD}" in
        scp)
index 3a3da897f212d000c5423c357e0d6e6f81e2ea99..632f79491ff7d6bff94192a09e47a0d15e3e93e7 100644 (file)
@@ -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
 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
 
 XFER_METHOD=scp
 XFER_USER=backup
index 2967c12354e92d54e5fba23796f300b0fb3773d3..4e828e6dbfd24ed9753cce8f44decfeb1a0eda41 100755 (executable)
@@ -2,7 +2,7 @@
 . $1
 FILENAME=${FULLNAME}${APPEND}
 cd ${STORAGE}
 . $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
 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