From dd0a6b266247559fc6dc46e322fe1350e19f9dc0 Mon Sep 17 00:00:00 2001 From: "d. johnson" Date: Sat, 26 Apr 2014 20:33:10 -0500 Subject: Add sample backup script --- duplicity-backups.sh | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100755 duplicity-backups.sh diff --git a/duplicity-backups.sh b/duplicity-backups.sh new file mode 100755 index 0000000..90d6f73 --- /dev/null +++ b/duplicity-backups.sh @@ -0,0 +1,142 @@ +#!/bin/bash +# +# This script was created to make Duplicity backups. Full backups are made on +# Sundays. Then incremental backups are made on the other days. +# +# Basic rule: dont backup packaged data, only unpackaged files, and changed config files +# +# Step 1) sudo yum install duplicity gnupg openssh-clients +# Step 2) Create /root/.passphrase with some phrase you will remember. +# Step 3) Edit the BACKUP_URL below. +# Step 4) Copy this file to /etc/cron.daily/ + +# User settings: +# Where to upload the backups +BACKUP_URL="sftp://User@BackupHost.local.lan//home/duplicity/$HOSTNAME/" + +# Extra duplicity options +EXTRA_DUPLICITY="--allow-source-mismatch --extra-clean" + +# Loading the day of the month in a variable. +DOW=$(/bin/date +%u) +TMPDIR=/root/tmp + +# Check to see if we have a SSH key +if [ ! -e /root/.ssh/id_rsa ]; then + /bin/cat - < /root/tmp/gnupg-batch.txt < /root/.gnupg/root-privkey.asc + /bin/chmod 0400 /root/.gnupg/root-privkey.asc + /usr/bin/gpg --export --armor root@$HOSTNAME > /root/.gnupg/root-pubkey.asc + /bin/rm /root/tmp/gnupg-batch.txt + exit 1 +fi + +# Generate some base OS configs +[ -d "${TMPDIR}" ] || mkdir -p "${TMPDIR}" +/usr/bin/show-installed -f kickstart -o ${TMPDIR}/SHOW-INSTALLED2.txt +/usr/bin/yum repolist > ${TMPDIR}/YUM-REPOLIST.txt +/usr/sbin/semanage -o ${TMPDIR}/SELINUX-CUSTOM-CONFIG.txt + +# Directories to backup +/bin/cat - > ${TMPDIR}/duplicity-backups.txt <