From f4324bf32a8d9c9efc535f88fb6c8fe7e132e154 Mon Sep 17 00:00:00 2001
From: Evan Broder <broder@mit.edu>
Date: Sat, 15 Nov 2008 11:49:24 -0500
Subject: [PATCH] Add xvm-db-backup package

svn path=/trunk/packages/xvm-db-backup/; revision=1656
---
 debian/changelog                 |    5 +++++
 debian/compat                    |    1 +
 debian/control                   |   14 ++++++++++++++
 debian/copyright                 |   17 +++++++++++++++++
 debian/rules                     |    3 +++
 debian/xvm-db-backup.cron.hourly |    3 +++
 debian/xvm-db-backup.install     |    1 +
 xvm-db-backup                    |   12 ++++++++++++
 8 files changed, 56 insertions(+)
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100755 debian/rules
 create mode 100755 debian/xvm-db-backup.cron.hourly
 create mode 100644 debian/xvm-db-backup.install
 create mode 100755 xvm-db-backup

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..b991ec9
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+xvm-db-backup (0.0.1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Evan Broder <broder@mit.edu>  Sat, 15 Nov 2008 11:34:36 -0500
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..f98939d
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,14 @@
+Source: xvm-db-backup
+Section: servers
+Priority: extra
+Maintainer: SIPB XVM Project <xvm@mit.edu>
+Build-Depends: cdbs, debhelper (>= 5)
+Standards-Version: 3.8.0
+
+Package: xvm-db-backup
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends},
+ debathena-kerberos-config, debathena-afs-config,
+ openafs-client, postgresql-client-common
+Description: Configure the database backup on XVM servers
+ Backup the XVM database to AFS hourly
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..381dc35
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,17 @@
+This software was written for the XVM project <xvm@mit.edu>
+of the MIT Student Information Processing Board.
+
+Copyright :
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+On Debian systems, the complete text of the GNU General Public License
+can be found in the file /usr/share/common-licenses/GPL.
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..e6192f6
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,3 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
diff --git a/debian/xvm-db-backup.cron.hourly b/debian/xvm-db-backup.cron.hourly
new file mode 100755
index 0000000..484f6db
--- /dev/null
+++ b/debian/xvm-db-backup.cron.hourly
@@ -0,0 +1,3 @@
+#!/usr/bin/pagsh
+
+exec /usr/sbin/xvm-db-backup
diff --git a/debian/xvm-db-backup.install b/debian/xvm-db-backup.install
new file mode 100644
index 0000000..d8f74b8
--- /dev/null
+++ b/debian/xvm-db-backup.install
@@ -0,0 +1 @@
+xvm-db-backup usr/sbin
diff --git a/xvm-db-backup b/xvm-db-backup
new file mode 100755
index 0000000..d16c23e
--- /dev/null
+++ b/xvm-db-backup
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+kinit -k "daemon/$(hostname -f)"
+aklog sipb
+
+filename="$(date +%Y-%m-%d-%H-%M.sql.gz)"
+
+/usr/bin/pg_dump -U "$(invirt-getconf db.user)" \
+                 -h "$(invirt-getconf db.host)" \
+                 "$(invirt-getconf db.dbname)" | gzip - >"$filename"
-- 
1.7.9.5