initial attempt at delete_old function
This commit is contained in:
parent
ba60880621
commit
f367c43649
1 changed files with 30 additions and 32 deletions
|
@ -104,13 +104,14 @@ verbose() {
|
||||||
# delete old backups
|
# delete old backups
|
||||||
delete_old() {
|
delete_old() {
|
||||||
#
|
#
|
||||||
if test -n $BU_FROOT && test -n $BU_TO_KEEP ; then
|
verbose "deleting old files based on $1"
|
||||||
# pattern to search for to build the list...
|
# pattern to search for to build the list...
|
||||||
PATTERN="$BU_DIR/$BU_FROOT-*.*"
|
PATTERN="$BU_DIR/$1-*.*"
|
||||||
# build the list, with the suffix...
|
# build the list, with the suffix...
|
||||||
PRUNEABLES=`$PRUNEABLES_CMD $PATTERN`
|
PRUNEABLES=`$PRUNEABLES_CMD $PATTERN`
|
||||||
if test "$?" -eq "0" ; then
|
if test "$?" -eq "0" ; then
|
||||||
message "pruning older files based on $PATTERN.$BU_SUFFIX"
|
message "pruning older files based on $PATTERN"
|
||||||
|
BU_TO_KEEP=$BU_TO_KEEP_${!2}
|
||||||
message "keeping last $BU_TO_KEEP backups"
|
message "keeping last $BU_TO_KEEP backups"
|
||||||
#
|
#
|
||||||
# set counter
|
# set counter
|
||||||
|
@ -121,15 +122,12 @@ delete_old() {
|
||||||
NUM=$(($NUM + 1))
|
NUM=$(($NUM + 1))
|
||||||
if test $NUM -gt $BU_TO_KEEP ; then
|
if test $NUM -gt $BU_TO_KEEP ; then
|
||||||
message "deleting $PRUNEABLE"
|
message "deleting $PRUNEABLE"
|
||||||
rm $PRUNEABLE 2>&1 > /dev/null
|
#rm $PRUNEABLE 2>&1 > /dev/null
|
||||||
else
|
else
|
||||||
message "keeping $PRUNEABLE"
|
message "keeping $PRUNEABLE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
message "keeping older backups, missing backup_root_filename..."
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -199,22 +197,22 @@ verbose "going to $DC_DIR"
|
||||||
OLD_DIR=`pwd`
|
OLD_DIR=`pwd`
|
||||||
cd $DC_DIR
|
cd $DC_DIR
|
||||||
#
|
#
|
||||||
# run the backup...
|
|
||||||
#
|
|
||||||
# a timestamp for logging purposes
|
# a timestamp for logging purposes
|
||||||
STAMP=`date '+%Y-%m-%d_%H-%M-%S'`
|
STAMP=`date '+%Y-%m-%d_%H-%M-%S'`
|
||||||
# delete stale backups
|
|
||||||
#
|
|
||||||
# delete_old
|
|
||||||
#
|
#
|
||||||
# generate the filename
|
# generate the filename
|
||||||
INC="BU_FROOT_$TASK"
|
INC="BU_FROOT_$TASK"
|
||||||
FILENAME=$BU_FROOT-${!INC}-$STAMP.sql
|
FILEPART=$BU_FROOT-${!INC}
|
||||||
|
FILENAME=$FILEPART-$STAMP.sql
|
||||||
FILEPATH=$BU_DIR/$FILENAME
|
FILEPATH=$BU_DIR/$FILENAME
|
||||||
|
#
|
||||||
|
# delete stale backups
|
||||||
|
delete_old $FILEPART
|
||||||
|
#
|
||||||
message "backing up all the databases into $FILEPATH"
|
message "backing up all the databases into $FILEPATH"
|
||||||
# dump the data into the file
|
# dump the data into the file
|
||||||
#
|
#
|
||||||
do_backup $FILEPATH
|
do_backup $FILEPATH $TASK
|
||||||
#
|
#
|
||||||
message "completed backup"
|
message "completed backup"
|
||||||
# compress the backup
|
# compress the backup
|
||||||
|
|
Loading…
Reference in a new issue