Permalink
Browse files

Use separate state directory for timer script

After a backup is completed, update a state directory outside the backup
directory with the current symlinks and timestamp files.  Update the
timer script to use this state directory instead of the backup directory
to avoid spinning up the backup drives if no backup is needed.

Move the client_lockdir out of the backup directory as well.
  • Loading branch information...
cwarden committed Nov 3, 2013
1 parent 138ee4b commit 237aecfde0089f9bd8563eb03964a91eeeea30d2
Showing with 46 additions and 1 deletion.
  1. +2 −0 configs/server/burp.conf
  2. +5 −1 configs/server/timer_script
  3. +39 −0 configs/server/update_state_dir
@@ -5,6 +5,7 @@ port = 4971
status_port = 4972
directory = /var/spool/burp
clientconfdir = /etc/burp/clientconfdir
client_lockdir=/var/run/burp
pidfile = /var/run/burp.server.pid
hardlinked_archive = 0
working_dir_recovery_method = delete
@@ -128,6 +129,7 @@ timer_arg = Sat,Sun,00,01,02,03,04,05,06,07,08,17,18,19,20,21,22,23
# minutes. Requires notify_failure_script to be set above.
#server_script_pre_notify = 0
#server_script_post =
server_script_post = /etc/burp/update_state_dir
#server_script_post_arg =
#server_script_post_arg =
#server_script_post_run_on_fail=0
@@ -12,11 +12,15 @@ reserved2="$1" ; shift
interval="$1" ; shift
timestamp="$current/timestamp"
state_dir="/var/run/burp/state"
current="${current/$storage_dir/$state_dir}"
timestamp="${timestamp/$storage_dir/$state_dir}"
# A 'backup' file placed in the storage directory tells this script that
# a backup needs to be done right now.
# This gives the 'server initiates a manual backup' feature.
manual_file="$storage_dir/$client/backup"
manual_file="$state_dir/$client/backup"
if [ -f "$manual_file" ] ; then
echo "Found $manual_file"
echo "Do a backup of $client now"
@@ -0,0 +1,39 @@
#!/bin/bash
echo "Running update_state_dir script: $@"
preorpost="$1" ; shift
action="$1" ; shift # either "backupphase1" or "backupphase1timed"
client="$1" ; shift
success="$1" ; shift
timer="$1" ; shift
usage()
{
echo "usage: $prog post [backupphase1|backupphase1timed] <client> [0|1] [0|1]" 1>&2
echo "The third argument is whether the backup succeeded (0 for ok)" 1>&2
echo "The fourth argument is whether the timer script allowed a backup (0 for ok)" 1>&2
exit 1
}
if [ -z "$preorpost" -o -z "$action" -o -z "$client" -o -z "$success" -o -z "timer" ] || [ "$preorpost" != "post" ]
then
usage
fi
if [ "$action" != "backupphase1" -a "$action" != "backupphase1timed" ] ; then
# It was not a backup that ran.
exit 0
fi
if [ "$action" = "backupphase1timed" ] && [ "$timer" != "0" ] ; then
# Server did not allow timed backup to be attempted.
exit 0
fi
if [ "$success" != "0" ] ; then
# Backup failed - do not run the offsite backup.
exit 0
fi
rsync -av --include '/*/' --include '/*/*/' --include '/*/current' --include '/*/*/timestamp' --include '/*/*/backup' --exclude '*' /media/freeagent/burp/ /var/run/burp/state

2 comments on commit 237aecf

@jkugler

This comment has been minimized.

jkugler replied Dec 19, 2013

I've not used Burp,so I could be completely off, but is the state dir supposed to be durable? If so, you might want to move it out of /var/run as some distros mount that in a ramdrive now.

@cwarden

This comment has been minimized.

Owner

cwarden replied Dec 19, 2013

@jkugler, it's safe for the data to be removed and regenerated upon reboot, but /var/cache would probably be more consistent with FHS guidelines. Thanks!

Please sign in to comment.