FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit de3a7f6f authored by Dr Catherine Pitt's avatar Dr Catherine Pitt
Browse files

Add prepare script that does not dump mysql or postgres

parent 04e7b9a0
No related branches found
Tags 0.9-ch73
No related merge requests found
......@@ -3,7 +3,7 @@ Priority: optional
Section: otherosfs
Maintainer: Frank Lee <rl201@cam.ac.uk>
Architecture: all
Version: 0.9-ch46
Version: 0.9-ch47
Depends: zfs-dkms, postgresql, liblockfile-simple-perl, libdbi-perl, libjson-perl, libzfs-perl-chem, libnet-openssh-perl, libdbd-pg-perl, mbuffer, rsync, nfs-kernel-server, pv
Description: a backup system using ZFS
Ported (well, mostly) from FreeBSD to a Sane OS.
#!/bin/bash
# A script which runs, largely on the remote machine, to prepare for backup
# Jobs to do:
# * Exclude files which are only found in packages
# * List all packages which are installed
# * (optionally) dump PostgreSQL into a file
# NB this is intended to be used in conjunction with a separate mysql backup
# task. To do this:
# 1) /usr/lib/chem-zfs-backup-server/new-backup-rsync $HOSTNAME mysql
# 2) add "--exclude=/var/lib/mysql --exclude=/var/lib/mysql-files" to
# to zfs-rsync.d config for $HOSTNAME
CONFDIR=/etc/chem-zfs-backup-server/zfs-rsync.d
SSH="ssh -p ${SSHPORT:-22} -o ConnectTimeout=10"
SCP="scp -P ${SSHPORT:-22}"
#echo $SSH
set -xv
SERVER=$1
if [ -z $SERVER ] ; then
echo $0 Server
exit 1
fi
(
# Has the package status changed since last time we generated the list of files?
if $SSH root@$SERVER [ /var/lib/dpkg/status -nt /var/adm/backup/package-files ] ; then
# Need to rebuild package-files
$SSH root@$SERVER "
umask 077
FILELIST=\`tempfile\`
CONFLIST=\`tempfile\`
mkdir -p /var/adm/backup
# Make logrotate use datestamps
if ! grep -q dateext /etc/logrotate.conf ; then sed -i 's/^include/dateext\ninclude/' /etc/logrotate.conf ; fi
# Which packages are installed?
dpkg --get-selections | awk ' { print \$1 ; } ' >/var/adm/backup/packages
cat /var/lib/dpkg/info/*.list | while read F ; do [ -f \"\$F\" ] && echo \"\$F\" ; done | sort > \$FILELIST
awk '/Description:/ { flag = 0 } ; flag == 1 { print \$1 ; } ; /Conffiles:/ { flag = 1 } ; ' </var/lib/dpkg/status | sort >\$CONFLIST
diff -u \$FILELIST \$CONFLIST | grep ^-/ | sed s/^-// >/var/adm/backup/package-files
rm $FILELIST $CONFLIST
"
mkdir -p $CONFDIR/$SERVER
$SCP -q root@$SERVER:/var/adm/backup/package-files $CONFDIR/$SERVER/exclude
fi
# Ensure that the excludes file exists, even if we haven't updated it this time
if [ ! -f $CONFDIR/$SERVER/exclude ] ; then
mkdir -p $CONFDIR/$SERVER
$SCP -q root@$SERVER:/var/adm/backup/package-files $CONFDIR/$SERVER/exclude
fi
$SSH root@$SERVER "
# Ensure that things are not readable where they ought not to be
umask 077
# Save the package configuration info
which debconf-get-selections >/dev/null 2>&1 || apt-get install debconf-utils
which rsync >/dev/null 2>&1 || apt-get install rsync
debconf-get-selections >/var/adm/backup/debconf
# Dump LDAP, if we can
which slapcat >/dev/null 2>&1 && slapcat >/var/adm/backup/ldap
# Ignore exit status of this command
true
"
echo Prepared $SERVER `date`
) >/var/log/chem-zfs-backup-server/${SERVER}-prepare 2>&1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment