← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3886: Added simple cron backup scripts. Based on a script Jason provided.

 

------------------------------------------------------------
revno: 3886
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-06-13 14:02:17 +0200
message:
  Added simple cron backup scripts. Based on a script Jason provided.
added:
  resources/cron/
  resources/cron/pg_backup.cron
  resources/cron/pg_backup.sh


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'resources/cron'
=== added file 'resources/cron/pg_backup.cron'
--- resources/cron/pg_backup.cron	1970-01-01 00:00:00 +0000
+++ resources/cron/pg_backup.cron	2011-06-13 12:02:17 +0000
@@ -0,0 +1,1 @@
+0 23 * * * /usr/local/bin/pg_backup.sh

=== added file 'resources/cron/pg_backup.sh'
--- resources/cron/pg_backup.sh	1970-01-01 00:00:00 +0000
+++ resources/cron/pg_backup.sh	2011-06-13 12:02:17 +0000
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# The backupdir must be created manually (mkdir pg_backups)
+# The backupdir owner must be changed to postgres (chown postgres pg_backups)
+# Script must be made executable (chmod 755 pg_backup.sh)
+# Script must be invoked by postgres user
+
+backup_dir="/var/backups/pg_backups"
+datetime=`date +%F`
+backupfile="$backup_dir/pg-backup-$datetime.gz"
+
+echo "Starting backup..."
+
+/usr/bin/pg_dump dhis2ke -U postgres | gzip > $backupfile
+
+timeinfo=`date '+%T %x'`
+
+echo "Backup file $backupfile complete at $timeinfo"