From d640ee65eea07df681dd1d6bf64bafb8f61e1897 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 2 Mar 2012 14:46:15 +0000 Subject: [PATCH 1/2] Monotone-Parent: 40141d367c9c6560edf3b306cee2aa7683dad3ec Monotone-Revision: c46ffb7bfa2e724959729ad762023fc8a8e92973 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-03-02T14:46:15 --- SoObjects/SOGo/GNUmakefile.preamble | 1 + 1 file changed, 1 insertion(+) diff --git a/SoObjects/SOGo/GNUmakefile.preamble b/SoObjects/SOGo/GNUmakefile.preamble index ee71f35ab..b65dfd362 100644 --- a/SoObjects/SOGo/GNUmakefile.preamble +++ b/SoObjects/SOGo/GNUmakefile.preamble @@ -13,6 +13,7 @@ ADDITIONAL_CPPFLAGS += \ -DSOGO_LIBDIR="\"$(SOGO_LIBDIR)\"" SOGo_LIBRARIES_DEPEND_UPON += \ + -Wl,--no-as-needed \ -L../../OGoContentStore/$(GNUSTEP_OBJ_DIR)/ -lOGoContentStore \ -L../../SOPE/NGCards/$(GNUSTEP_OBJ_DIR)/ \ -lmemcached \ From f223156046d9793f1d3410e7d39fb1379216d351 Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Fri, 2 Mar 2012 15:36:12 +0000 Subject: [PATCH 2/2] * Scripts/sogo-backup.sh: new script to automate backups. Updated sogo.cron to include a commented out entry for sogo-backup.sh Include updates.php in the packages Monotone-Parent: c46ffb7bfa2e724959729ad762023fc8a8e92973 Monotone-Revision: 2db05edf03ab8974bf7e72c13532434b264cff3d Monotone-Author: jraby@inverse.ca Monotone-Date: 2012-03-02T15:36:12 --- ChangeLog | 6 ++++ Scripts/sogo-backup.sh | 67 ++++++++++++++++++++++++++++++++++++++++++ Scripts/sogo.cron | 7 +++++ debian/sogo.docs | 4 ++- sogo.spec | 2 +- 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100755 Scripts/sogo-backup.sh diff --git a/ChangeLog b/ChangeLog index 017d6a2c1..5179e5f8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-03-02 Jean Raby + + * Scripts/sogo-backup.sh: new script to automate backups. + Updated sogo.cron to include a commented out entry for sogo-backup.sh + Include updates.php in the packages + 2012-03-01 Wolfgang Sourdeau * SoObjects/SOGo/LDAPSource.m (_convertRecordToLDAPAttributes): diff --git a/Scripts/sogo-backup.sh b/Scripts/sogo-backup.sh new file mode 100755 index 000000000..58cffa445 --- /dev/null +++ b/Scripts/sogo-backup.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -o pipefail + +set -x +PROGNAME="$(basename $0)" + +BACKUP_DIR=/home/sogo/backups +SOGO_TOOL=/usr/sbin/sogo-tool +DAYS_TO_KEEP="30" + +DATE=$(date +%F_%H%M) +LOG="logger -t $PROGNAME -p daemon.info" + +# log to stdout if on a tty +tty -s && LOG="cat -" + +function initChecks { + if [ ! -d "$BACKUP_DIR" ]; then + mkdir -m700 -p "$BACKUP_DIR" + if [ $? -ne 0 ]; then + echo "BACKUP_DIR doesn't exist and couldn't create it, aborting ($BACKUP_DIR)" | $LOG + exit 1 + fi + fi + + if [ ! -w "$BACKUP_DIR" ]; then + echo "$BACKUP_DIR not writable. Aborting" | $LOG + exit 1 + fi +} + +function removeOldBackups { + + if [ ! -z $DRYRUN ]; then + RM="echo \"not deleted\"" + else + RM="rm -rf" + fi + + echo "Deleting old backups..." | $LOG + find ${BACKUP_DIR}/ -maxdepth 1 -type d -iname "sogo-*" -mtime "+$DAYS_TO_KEEP" -ls -exec $RM {} \; 2>&1 | $LOG + echo "Done deleting old backups." | $LOG +} + + +function dumpit { + mkdir -m700 "$BACKUP_DIR/sogo-${DATE}" 2>&1 | $LOG + if [ $? -ne 0 ]; then + exit 1 + fi + $SOGO_TOOL backup "$BACKUP_DIR/sogo-${DATE}/" ALL 2>&1 | $LOG + RC=$? + if [ $RC -ne 0 ]; then + echo -e "FAILED, error while dumping sogo data" | $LOG + exit $RC + else + echo -e "OK: dumped sogo data" | $LOG + fi +} + +echo "$PROGNAME starting" | $LOG +initChecks +dumpit +removeOldBackups +echo "$PROGNAME exiting" | $LOG + + diff --git a/Scripts/sogo.cron b/Scripts/sogo.cron index 17b796820..350c2d50f 100644 --- a/Scripts/sogo.cron +++ b/Scripts/sogo.cron @@ -6,3 +6,10 @@ # Email alarms - runs every minutes #* * * * * sogo /usr/sbin/sogo-ealarms-notify + +# Daily backups +# - writes to /home/sogo/backups/ by default +# - will keep 31 days worth of backups by default +# - runs once a day by default, but can run more frequently +# - make sure to set the path to sogo-backup.sh correctly +#30 0 * * * sogo /usr/share/doc/sogo/sogo-backups.sh diff --git a/debian/sogo.docs b/debian/sogo.docs index 0ebd68c03..02b9d95c5 100644 --- a/debian/sogo.docs +++ b/debian/sogo.docs @@ -5,4 +5,6 @@ Scripts/sql-update-1.2.2_to_1.3.0-mysql.sh Scripts/sql-update-1.3.3_to_1.3.4.sh Scripts/sql-update-1.3.3_to_1.3.4-mysql.sh Scripts/sql-update-1.3.11_to_1.3.12.sh -Scripts/sql-update-1.3.11_to_1.3.12-mysql.sh \ No newline at end of file +Scripts/sql-update-1.3.11_to_1.3.12-mysql.sh +Scripts/sogo-backup.sh +Scripts/updates.php diff --git a/sogo.spec b/sogo.spec index 5a8e6e148..8d6a15105 100644 --- a/sogo.spec +++ b/sogo.spec @@ -234,7 +234,7 @@ rm -fr ${RPM_BUILD_ROOT} %config(noreplace) %{_sysconfdir}/cron.d/sogo %config(noreplace) %{_sysconfdir}/httpd/conf.d/SOGo.conf %config(noreplace) %{_sysconfdir}/sysconfig/sogo -%doc ChangeLog NEWS Scripts/sql*sh +%doc ChangeLog NEWS Scripts/*sh Scripts/updates.php %files -n sogo-tool %{_sbindir}/sogo-tool