]> oss.titaniummirror.com Git - ovzbpc.git/blobdiff - bpcbackup
Add bpcbackup wrapper, create crontab file to run bpcbackup. Some fixes to
[ovzbpc.git] / bpcbackup
diff --git a/bpcbackup b/bpcbackup
new file mode 100755 (executable)
index 0000000..ad4db0a
--- /dev/null
+++ b/bpcbackup
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# bpcbackup
+# Copyright (C) 2008 by Titanium Mirror, Inc.
+# Author: R. Steve McKown <smckown@titaniummirror.com>
+#
+# A wrapper script for bpcdump, designed to be called from root's crontab
+# on the HNs.  Only the HN hosting the BPC VE will do anything.
+
+VEID=1158
+
+# Complain if this script is running on a server not configured with OpenVZ
+if [ ! -x /usr/sbin/vzctl ]; then
+    echo "Host $(hostname) has bpcbackup installed, but is not an HN" >&2
+    exit 1
+fi
+
+# Silently exit if this script is running on an HN but not currently hosting
+# the BPC VE.
+if vzctl status "$VEID" 2>/dev/null | grep -q deleted; then
+    exit 0
+fi
+
+# OK, we're an HN and we're hosting the VE.  Run bpcbackup.  When it returns,
+# we want to unmount the esata drive to reduce the chance of damage to the
+# backup data.  Note, however, that esata must already be mounted or bpcdump
+# will error.  This is correct, since we cannot auto-mount esata, since it
+# has to be physically connected first, and may require authentication on mount
+# if the volume is encrypted.
+bpcdump
+esata umount