backup_diff.sh, backup_full.sh: Cleaned up for publication, added rsync transfer...
authorMegaBrutal <code+git@megabrutal.com>
Wed, 2 Sep 2015 20:32:55 +0000 (22:32 +0200)
committerMegaBrutal <code+git@megabrutal.com>
Wed, 2 Sep 2015 20:32:55 +0000 (22:32 +0200)
- 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

fs/backup_diff.sh [changed mode: 0644->0755]
fs/backup_fsdiff.conf [new file with mode: 0644]
fs/backup_full.sh [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 404b5e3..01145bd
@@ -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 (file)
index 0000000..3a3da89
--- /dev/null
@@ -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=
old mode 100644 (file)
new mode 100755 (executable)
index 404b5e3..2967c12
@@ -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