Subject Re: Looking for Linux backup script
Author Lou
Hello,

I have to give a big thanks to Ian for sharing his script, which after
some tinkering I modified to read a text file containing the database
name etc... My plan is to have a program generate the text file or
possibly read my firebird alias file and generate it each night before
the backup runs.

Ultimately the text file will only contain the datbae name and the
user name and password will be coded in script.

#!/bin/bash

BASE_SRC=/fbdata
BASE_TARGET=/fbsave
SOURCE_FILE_DIR=/fbsave/src
EMAIL=lou@.....
fbusr=SYSDBA
fbpw=[your password]

today=`date +%w`

# Create text file in directory containing
# database

# Declare array and loop through file

declare -a fbname

for x in $(seq $(grep -c $ dblist.txt))
do
x=$(($x))
line="$(sed -n ${x}p dblist.txt)"
fbname[$x]="${line:0:60}"
done


if [ "$today" = "0" ]; then
today=Week`date +%V`
ls -tl $BASE_TARGET | grep -E "^Week[0-9]?[0-9]/$" | tail -n +5 |
xargs rm -fR
else
today=`date +%A`
fi

mkdir $BASE_TARGET/$today 2>/dev/null
rm $BASE_TARGET/Current -f 2>/dev/null
ln -s $BASE_TARGET/$today $BASE_TARGET/Current

BASE_TARGET=$BASE_TARGET/Current

for y in $(seq $x)
do

DATABASE=${fbname[$y]}
source=${fbname[$y]}
target=`basename $source`
target=$BASE_TARGET/${target%.???}.fbk
user=$fbusr
password=$fbpw

/opt/firebird/bin/gbak -B -user $user -password $password $source
$target 2> backup.err
/opt/firebird/bin/gbak -C -user $user -password $password $target
$BASE_TARGET/restore.fdb 2>> backup.err
rm -f $BASE_TARGET/restore.fdb
if [ -s $backup.err ]; then
echo "Problem backing up or restoring"
mail -s "Error backing up $source on $destination" $EMAIL <
backup.err
fi

tar -czf $target.tgz $target
rm -f $BASE_TARGET/*.fbk
done