diff options
-rw-r--r-- | backup.in | 1 | ||||
-rw-r--r-- | lib/beam/common.in | 17 | ||||
-rw-r--r-- | lib/beam/s3.sh | 12 |
3 files changed, 26 insertions, 4 deletions
@@ -122,6 +122,7 @@ backup() { } umask ${backup_umask:-077} +prologue_hook="beam_lock $prologue_hook" if [ -n "$backup_logfile" ]; then runhook openlog_hook diff --git a/lib/beam/common.in b/lib/beam/common.in index 1be075e..7e69640 100644 --- a/lib/beam/common.in +++ b/lib/beam/common.in @@ -30,6 +30,7 @@ backup_archive_dir= backup_snapshot_dir= backup_verbose= backup_logfile="/var/log/backup" +backup_pidfile="/var/run/beam.pid" backup_tmp_dir=/tmp error() { @@ -47,6 +48,22 @@ abend() { exit $ec } +beam_lock() { + if [ -r $backup_pidfile ]; then + pid=$(head -n 1 $backup_pidfile) + if [ -z "$pid" ]; then + abend "pidfile $backup_pidfile exists but is unreadable or empty" + fi + abend "another beam process (pid $backup_pid) is still running; exiting" + fi + echo $$ > $backup_pidfile || exit 1 + epilogue_hook="$epilogue_hook beam_unlock" +} + +beam_unlock() { + rm -f $backup_pidfile +} + tarcode() { case $1 in 0) logit "success";; diff --git a/lib/beam/s3.sh b/lib/beam/s3.sh index de71456..d2fcfe6 100644 --- a/lib/beam/s3.sh +++ b/lib/beam/s3.sh @@ -26,9 +26,16 @@ test -z "$backup_mp" && backup_mp_s3=/mnt/s3 s3_getmpoint() { case $1 in +# Sample mount output, split into several lines: +# a) With --vhost: +# http://BUCKETNAME.s3.amazonaws.com/ on /mnt/s3backer type fuse.s3backer +# (rw,nosuid,nodev,allow_other,default_permissions) +# b) Without --vhost: +# http://s3.amazonaws.com/BUCKETNAME/ on /mnt/s3backer type fuse.s3backer +# (rw,nosuid,nodev,allow_other,default_permissions) backer) mount -tfuse.s3backer | - awk '/https?:\/\/'$backup_bucket_name'/ { print $3 }';; + awk '/https?:\/\/.*'$backup_bucket_name'/ { print $3 }';; s3) s=$(mount | grep "^${backup_mp_s3backer}/file" | awk '{ print $3 }') if [ -z "$s" ]; then @@ -50,9 +57,6 @@ s3_mount() { test -d $backup_mp_s3backer || mkdir $backup_mp_s3backer test -d $backup_mp_s3 || mkdir $backup_mp_s3 -# Sample mount output, split into several lines: -# http://finox-backup-fs.s3.amazonaws.com/ on /mnt/s3backer type fuse.s3backer -# (rw,nosuid,nodev,allow_other,default_permissions) set -- $(s3_getmpoint backer) if test -z "$1"; then $dry_run s3backer $backup_s3backer_options \ |