Subject | Re: Looking for Linux backup script |
---|---|
Author | Lou |
Post date | 2005-11-29T13:03:36Z |
Ian,
Thanks for replying. I will study this and adapt to my installation.
Question: Are you saying that you have a directory that
SOURCE_FILE_DIR points to where there is a file for each database and
the name of the file is "abc.fdb userid password" and the loop
reads them in to an array called database and that is how it extracts
the parameters?
I will give it a try later today.
- lou
Thanks for replying. I will study this and adapt to my installation.
Question: Are you saying that you have a directory that
SOURCE_FILE_DIR points to where there is a file for each database and
the name of the file is "abc.fdb userid password" and the loop
reads them in to an array called database and that is how it extracts
the parameters?
I will give it a try later today.
- lou
--- In firebird-support@yahoogroups.com, "Ian A. Newby" <ian@c...> wrote:
>
> Hi Lou,
> Here mine.
> It creates a backup directory named for the day of the week (except
> for sunday, when it names it with the week number). It then Symlinks a
> Current directory to point to the current backup directory. This is
> used by a different script which fetches the backups to a different
> server.
> Then it cycles through the files in the SOURCE_FILE_DIR, which are
> formatted like this...
>
> /data/aktiv.fdb <USER> <PASSWORD>
> /data/TMILeanMan.fdb <USER> <PASSWORD>
> /data/TMI_PSC.fdb <USER> <PASSWORD>
> /data/awards.fdb <USER> <PASSWORD>
> /data/RiskAssessment.fdb <USER> <PASSWORD>
>
> and backs them up and restores them. For each file in the directory,
> it then tar gzips it with the name of the tgz file the same as the
> source file.
>
> If there are any errors it emails the users specified.
> Hope you find it useful.
>
> ==================================================================
> #!/bin/bash
>
> BASE_TARGET=/data/Backup
> SOURCE_FILE_DIR=/root/backup/source
> EMAIL=iann@s...
>
> today=`date +%w`
>
> 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 destination in `ls $SOURCE_FILE_DIR`
> do
> echo $destination
> while read database
> do
> DATABASE=(${database})
> echo $DATABASE
> source=${DATABASE[0]}
> target=`basename $source`
> target=$BASE_TARGET/${target%.???}.fbk
> user=${DATABASE[1]}
> password=${DATABASE[2]}
> /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
>
> done < $SOURCE_FILE_DIR/$destination
>
> tar -czf $BASE_TARGET/$destination.tgz $BASE_TARGET/*.fbk
> rm -f $BASE_TARGET/*.fbk
> done
>
> ================================================================
>