Navigation Menu

Skip to content

Commit

Permalink
Use separate state directory for timer script
Browse files Browse the repository at this point in the history
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 237aecf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions configs/server/burp.conf
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion configs/server/timer_script
Expand Up @@ -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"
Expand Down
39 changes: 39 additions & 0 deletions configs/server/update_state_dir
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.