Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 45e32e0b89
Fetching contributors…

Cannot retrieve contributors at this time

executable file 43 lines (36 sloc) 1.433 kb
#!/bin/bash
#
# (c) 2006, 2010 tummy.com, ltd.
#
# Backup critical vPostMaster files to /var/spool/vpostmaster
FILE_LIST="usr/lib/vpostmaster/etc etc/dovecot* etc/postfix*"
FILE_LIST="$FILE_LIST etc/squirrelmail usr/share/squirrelmail/plugins"
FILE_LIST="$FILE_LIST var/lib/squirrelmail/data"
FILE_LIST="$FILE_LIST usr/lib/sasl2/smtpd.conf"
FILE_LIST="$FILE_LIST etc/sysconfig/saslauthd"
FILE_LIST="$FILE_LIST etc/default/saslauthd"
SAVE_DIR=/var/spool/vpostmaster
DUMP_NAME=vpostmaster-database.sql.bz2
BKUP_NAME=vpostmaster-configfiles.tar.bz2
[ -d "$SAVE_DIR" ] || install -d --ovpostmaster -m700 "$SAVE_DIR"
umask 077
( cd /tmp/; su postgres -c 'psql -d vpostmaster \
-c "select 1"' >/dev/null 2>&1 ) &&
( su postgres -c "cd /tmp; pg_dump vpostmaster" | \
bzip2 -1 > "$SAVE_DIR/$DUMP_NAME".tmp )
# Prune out files that don't exist
cd /
NEW_FILE_LIST=""
for FILE in $FILE_LIST; do
[ -e /"$FILE" ] && NEW_FILE_LIST="$NEW_FILE_LIST $FILE"
done
FILE_LIST="$NEW_FILE_LIST"
tar -cf - $FILE_LIST 2>/dev/null | bzip2 -1 >"$SAVE_DIR/$BKUP_NAME".tmp
[ -e "$SAVE_DIR/$DUMP_NAME".tmp ] \
&& mv "$SAVE_DIR/$DUMP_NAME".tmp "$SAVE_DIR/$DUMP_NAME" \
&& chown vpostmaster:root "$SAVE_DIR/$DUMP_NAME" \
&& chmod 400 "$SAVE_DIR/$DUMP_NAME"
[ -e "$SAVE_DIR/$BKUP_NAME".tmp ] \
&& mv "$SAVE_DIR/$BKUP_NAME".tmp "$SAVE_DIR/$BKUP_NAME" \
&& chown vpostmaster:root "$SAVE_DIR/$BKUP_NAME" \
&& chmod 400 "$SAVE_DIR/$BKUP_NAME"
Jump to Line
Something went wrong with that request. Please try again.