1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-07-13 07:14:39 +03:00

Add functionality to delete old backups

This commit is contained in:
SoarinFerret
2019-12-24 09:06:04 +00:00
committed by Markus
parent 766e9bbd0b
commit 54e734beb0
3 changed files with 16 additions and 2 deletions

View File

@ -7,13 +7,20 @@ fi
if [ $TIMESTAMP = true ]
then
BACKUP_FILE="$(echo "$BACKUP_FILE")_$(date "+%F-%H%M%S")"
FINAL_BACKUP_FILE="$(echo "$BACKUP_FILE")_$(date "+%F-%H%M%S")"
else
FINAL_BACKUP_FILE=$BACKUP_FILE
fi
/usr/bin/sqlite3 $DB_FILE ".backup $BACKUP_FILE"
/usr/bin/sqlite3 $DB_FILE ".backup $FINAL_BACKUP_FILE"
if [ $? -eq 0 ]
then
echo "$(date "+%F %T") - Backup successfull"
else
echo "$(date "+%F %T") - Backup unsuccessfull"
fi
if [ ! -z $DELETE_AFTER ] && [ $DELETE_AFTER -gt 0 ]
then
find $(dirname "$BACKUP_FILE") -name "$(basename "$BACKUP_FILE")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \;
fi