Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

123 lines (100 sloc) 3.015 kb
#!/bin/sh
set -e
KEYS='0x1D643B75'
HOST="$(hostname -f)"
backup_dpkg() {
dpkg --get-selections \
| ssh -q chaosdorf@lastlight.derf0.net "cat > backup/${HOST}_packages"
}
backup_ldap() {
slapcat \
2> /dev/null \
| gpg --encrypt --always-trust -r ${KEYS} \
| ssh -q chaosdorf@lastlight.derf0.net "cat > backup/${HOST}_ldap.gpg"
}
backup_mediawiki() {
php /srv/www/de.chaosdorf.wiki/maintenance/dumpBackup.php --quiet --full \
| xz \
| gpg --encrypt --always-trust -r ${KEYS} \
| ssh -q chaosdorf@lastlight.derf0.net "cat > backup/${HOST}_mediawiki.xml.xz.gpg"
}
backup_sql() {
sh sqldump.sh \
| gpg --encrypt --always-trust -r ${KEYS} \
| ssh -q chaosdorf@lastlight.derf0.net "cat > backup/${HOST}_sql.gpg"
}
backup_tar() {
# xzip is more space-efficinet than gzip and therefore preferred. However,
# it requires more RAM and CPU time, which should be avoided on embedded
# hosts.
if uname -m | grep -q '^armv'; then
tar --warning=no-file-ignored --warning=no-file-changed \
-C / -czf - "${1}" \
| gpg --encrypt --always-trust -r ${KEYS} \
| ssh -q chaosdorf@lastlight.derf0.net "cat > backup/${HOST}_${2}.tar.gz.gpg"
else
tar --warning=no-file-ignored --warning=no-file-changed \
-C / -cJf - "${1}" \
| gpg --encrypt --always-trust -r ${KEYS} \
| ssh -q chaosdorf@lastlight.derf0.net "cat > backup/${HOST}_${2}.tar.xz.gpg"
fi
}
# Do not run *.chaosdorf.de backups simultaneously,
# omit this check when run manually.
# Also, do not run them between 03:00 and 04:00 because of DSL reconnect
# (we start at 00:03)
if [ ! -t 0 ]; then
case "${HOST}" in
backend.chaosdorf.de) sleep 1h ;; # 01:03
extern.chaosdorf.de) sleep 8h ;; # 08:03
intern.chaosdorf.de) sleep 5h ;; # 05:03
shells.chaosdorf.de) sleep 4h ;; # 04:03
vm.chaosdorf.de) ;; # 00:03
esac
fi
if which dpkg > /dev/null 2>&1; then
backup_dpkg
fi
backup_tar boot boot
backup_tar etc etc
backup_tar root root
backup_tar var/log var_log
backup_tar usr/local usr_local
backup_tar var/local var_local
if ! echo "${HOST}" | fgrep -q .chaosdorf.dn42; then
backup_tar home home
backup_tar srv srv
fi
if echo echo "${HOST}" | fgrep -q -e feedback -e door -e donationprint -e unifiserver; then
backup_tar home home
fi
case "${HOST}" in
backend.chaosdorf.de)
backup_ldap
;;
dashboardserver.chaosdorf.dn42)
backup_tar srv srv
;;
extern.chaosdorf.de)
backup_mediawiki
backup_tar var/lib/automysqlbackup automysqlbackup
backup_sql
;;
intern.chaosdorf.de)
backup_sql
backup_tar var/lib/automysqlbackup automysqlbackup
backup_tar var/mail var_mail
;;
meteserver.chaosdorf.dn42)
rm -f /srv/mete/db-backup.sqlite3
echo .backup /srv/mete/db-backup.sqlite3 | sqlite3 /srv/mete/shared/db/production.sqlite3
backup_tar srv srv
;;
shells.chaosdorf.de)
backup_tar var/spool/cron crontabs
;;
esac
echo "${HOST}\tBackup\t0\tCompleted on $(date)" \
| send_nsca -H icinga.finalrewind.org \
> /dev/null
exit 0
Jump to Line
Something went wrong with that request. Please try again.