1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

Improve mssql backups (#298)

* Improve mssql backups

* Launch DB backup at 23:59
This commit is contained in:
Mart124
2018-05-29 14:17:43 +02:00
committed by Kyle Spearrin
parent ecf75c2a66
commit 8471f558e3
3 changed files with 10 additions and 9 deletions

View File

@ -1,7 +1,11 @@
#!/bin/sh
# Delete backup files older than 30 days
find /etc/bitwarden/mssql/backups/ -type f -name '*.BAK' -mindepth 1 -mtime +30 -delete
# Backup timestamp
export now=${1:-$(date +%Y%m%d_%H%M%S)}
# Do a new backup
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -i /backup-db.sql
# Delete backup files older than 30 days
grep -B1 "BACKUP DATABASE successfully" /var/opt/mssql/log/errorlog | grep -q _$now.BAK &&
find /etc/bitwarden/mssql/backups/ -mindepth 1 -type f -name '*.BAK' -mtime +32 -delete