Here is the script I use to kick of backups of not-always-there
machines. It's a little hacky, but does the job for me.
Some assumptions:
The client foo is the bacula file demon foo-fd
You want to run Differential backups of foo every day it is
actually available to be backed up.
You have a job which is sheduled never to run automatically which
when run by this script will do today's backup. For stupid shell
reasons it is important that the job name not contain spaces. In
the example below, FooJob.
The bacula console config on host bachost is
/usr/local/etc/bacula-bachost.conf
I have been thinking of extending this to be able to run a full backup
every month or similar, if anyone actually thinks this is interesting
enough to be worth working on I'll give it a go.
I run this every hour from root's crontab on the bacula director's
machine as follows.
bacula_backup_if_ready bachost foo-fd 1 FooJob
Meaning `talk to the bacula console on bachost and if foo has not been
backed up for at least 1 day, and it is up and available, back it up
by running FooJob.
I have only run this on FreeBSD, so there could be minor issues with
where things are related on other systems.
--- 8< --- 8< --- CUT HERE for bacula_backup_if_ready --- 8< --- 8< ---
#!/bin/sh
if [ $# -lt 3 ]
then
echo "Use: $0 HOST CLIENT DAYS" JOB1 JOB2...
exit 1
fi
# set -x
host=${1-`hostname`}
host=`expr "$host" : '^\([^.]*\).*'`
exec > /var/log/bacula_oportunistic-$host 2>&1
conf=/usr/local/etc/bacula-$host.conf
client="$2"
days="$3"
shift 3
client_host=`expr "$client" : '\(.*\)-fd'`
# Shell function which runs a command via the
# bacula console.
bacula_command()
{
t="$1"
c="$2"
shift 2
{ echo "$c"; for a in "$@" ; do echo "$a"; done; } | /usr/local/sbin/console -c
"$conf"&
bacula_pid=$!
(sleep $t; kill $bacula_pid 2>/dev/null >&2)&
wait $bacula_pid
}
# Check timestamp to see if we are due a backup.
[ -d /var/bacula_timestamps ] || mkdir /var/bacula_timestamps
timestamp=`find /var/bacula_timestamps -name $client -mtime -$days`
echo timestamp=$timestamp
if [ -z "$timestamp" ]
then
if /sbin/ping -c 1 $client_host && bacula_command 10 "status
client=$client"
then
for job in "$@"
do
if bacula_command 10 "run \"$job\"" "mod" "1" "4" "yes"
then
echo -n > /var/bacula_timestamps/$client
fi
done
fi
fi
--- 8< --- 8< --- bacula_backup_if_ready end --- 8< --- 8< ---
^_^
(O O)
\_/@@\
\\~~/
~~
- RJC
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bacula-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users