1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-01 13:43:23 +01:00
bitwarden-server/util/MsSql/backup-db.sh

12 lines
393 B
Bash
Raw Normal View History

#!/bin/sh
# Backup timestamp
export now=${1:-$(date +%Y%m%d_%H%M%S)}
2017-08-30 05:05:52 +02:00
# Do a new backup
2017-08-21 16:58:00 +02:00
/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