1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-24 17:17:40 +01:00

Allow for slight customization of the mssql db backup interval (#1008)

* Allow for slight customization of the mssql db backup interval

* Honor env TZ if set and clean up -u in sleep calculation
This commit is contained in:
David Lundgren 2020-12-15 10:08:30 -06:00 committed by GitHub
parent 25dff79527
commit d63eb376c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,14 @@
#!/bin/sh
BACKUP_INTERVAL=${BACKUP_INTERVAL:-next day}
BACKUP_INTERVAL_FORMAT=${BACKUP_INTERVAL_FORMAT:-%Y-%m-%d 00:00:00}
while true
do
# Sleep until next day
[ "$1" = "loop" ] && sleep $((24 * 3600 - (`date +%_H` * 3600 + `date +%_M` * 60 + `date +%_S`)))
if [ "$1" = "loop" ]; then
interval_start=`date "+${BACKUP_INTERVAL_FORMAT} %z" -d "${BACKUP_INTERVAL}"`
sleep $((`date +%_s -d "${interval_start}"` - `date +%_s`))
fi
# Backup timestamp
export now=$(date +%Y%m%d_%H%M%S)