mirror of
https://github.com/bitwarden/server.git
synced 2024-11-26 12:55:17 +01:00
8471f558e3
* Improve mssql backups * Launch DB backup at 23:59
12 lines
393 B
Bash
12 lines
393 B
Bash
#!/bin/sh
|
|
|
|
# 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
|