1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-06-28 07:38:15 +03:00
vwdump/backup.sh
2021-01-17 23:37:53 +01:00

29 lines
802 B
Bash

#!/bin/sh
# Check if db file is accessible and exit otherwise
if [ ! -e "$DB_FILE" ]
then
echo "Database $DB_FILE not found!\nPlease check if you mounted the bitwarden_rs volume with '--volumes-from=bitwarden'"!
exit 1;
fi
if [ $TIMESTAMP = true ]
then
FINAL_BACKUP_FILE="$(echo "$BACKUP_FILE")_$(date "+%F-%H%M%S")"
else
FINAL_BACKUP_FILE=$BACKUP_FILE
fi
/usr/bin/sqlite3 $DB_FILE ".backup $FINAL_BACKUP_FILE"
if [ $? -eq 0 ]
then
echo "$(date "+%F %T") - Backup successfull to $FINAL_BACKUP_FILE"
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