working backup script, with old backup removal and cron template
This commit is contained in:
parent
366728ccda
commit
794ca288a5
2 changed files with 27 additions and 7 deletions
18
dbbackup-cron
Normal file
18
dbbackup-cron
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#
|
||||||
|
# run system backups
|
||||||
|
#
|
||||||
|
# hourly - at 5 minutes past mon-sat
|
||||||
|
05 * * * * root /etc/dbbackup/dbbackup-docker-compose --hourly
|
||||||
|
#
|
||||||
|
# daily - at 7:30 pm, mon-sat
|
||||||
|
30 19 * * * root /etc/dbbackup/dbbackup-docker-compose --daily
|
||||||
|
#
|
||||||
|
# weekly - at 7:30 pm, sun
|
||||||
|
30 19 * * sun root /etc/dbbackup/dbbackup-docker-compose --weekly
|
||||||
|
#
|
||||||
|
# monthly - at 8:30 pm, on the first of the last of the month
|
||||||
|
30 20 1 * * root /etc/dbbackup/dbbackup-docker-compose --monthly
|
||||||
|
#
|
||||||
|
# yearly - at 8:30 pm, on the first of January.
|
||||||
|
30 20 1 1 * root /etc/dbbackup/dbbackup-docker-compose --yearly
|
||||||
|
|
|
@ -25,7 +25,7 @@ BU_FROOT_YEARLY=yearly
|
||||||
# this can be overridden at invocation
|
# this can be overridden at invocation
|
||||||
BU_CONF=default-docker-compose.conf
|
BU_CONF=default-docker-compose.conf
|
||||||
# # output for debugging...
|
# # output for debugging...
|
||||||
VERBOSE=1
|
VERBOSE=0
|
||||||
#
|
#
|
||||||
# Stuff that should be universal for this install...
|
# Stuff that should be universal for this install...
|
||||||
# where we can find this app...
|
# where we can find this app...
|
||||||
|
@ -111,8 +111,7 @@ delete_old() {
|
||||||
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"
|
message "pruning older files based on $PATTERN"
|
||||||
|
BU_TO_KEEP=$2
|
||||||
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
|
||||||
|
@ -123,11 +122,13 @@ 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
|
||||||
|
else
|
||||||
|
message "No files with $PATTERN to delete"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
|
@ -180,7 +181,7 @@ done
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# create the blank email report
|
# create the blank email report
|
||||||
#create_tmp_email
|
create_tmp_email
|
||||||
#
|
#
|
||||||
if test -f $BU_CONF ; then
|
if test -f $BU_CONF ; then
|
||||||
verbose "Reading default in $BU_CONF"
|
verbose "Reading default in $BU_CONF"
|
||||||
|
@ -208,7 +209,8 @@ FILENAME=$FILEPART-$STAMP.sql
|
||||||
FILEPATH=$BU_DIR/$FILENAME
|
FILEPATH=$BU_DIR/$FILENAME
|
||||||
#
|
#
|
||||||
# delete stale backups
|
# delete stale backups
|
||||||
delete_old $FILEPART $TASK
|
TO_KEEP="BU_TO_KEEP_$TASK"
|
||||||
|
delete_old $FILEPART ${!TO_KEEP}
|
||||||
#
|
#
|
||||||
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
|
||||||
|
@ -224,5 +226,5 @@ cd $OLD_DIR
|
||||||
#
|
#
|
||||||
# sent resulting email report
|
# sent resulting email report
|
||||||
#
|
#
|
||||||
#send_email_report
|
send_email_report
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue