Re: Automatic Backup Script Help
On Wed, May 23, 2012 at 08:30:29AM +0200, Craig A. Adams wrote:
> /data/backups/scripts/start-disk-1.sh
> #!/bin/bash
> echo /data/backups/scripts/backup-disk-1.sh | at now + 1 minute
>
> Is this the correct way to call the backup script, or is there a better way?
It doesn't seem like a bad idea; especially since you get some extras from at
(e.g. mail error output to user) for free. Another approach would be
{ sleep 60; /data/backups/scripts/backup-disk-1.sh } &
But I don't see why you even need the sleep.
> start_date_time='date +%Y-%m-%d-%H:%M:%S'
should be backticks here so that date is evaluated e.g.
start_date_time=`date +%Y-%m-%d-%H:%M:%S`
> if -a /data/backups/${backup_description}-in-progress; then
> echo "FAIL ${backup_description} backup already in progress."
> exit 1
> else touch /data/backups/${backup_description}-in-progress
> fi
There is a risk of race conditions here, if two instances of your script
are fired off at similar times. E.g., whilst instance #1 has performed
the check, instance #2 creates the file… Better would be a proper locking
solution. (sorry I'm not offering one in this reply)
> if ! mountpoint -q ${backup_target}/; then
risk of races here
> if ! mount ${backup_target}; then
and here
--
Jon Dowland
Reply to: