From e9ac54cebf2fbef5847d4e439fe1f8ff192a9e1b Mon Sep 17 00:00:00 2001 From: 10 <10@users.noreply.gitlab.com> Date: Sun, 18 Nov 2018 02:37:01 +0100 Subject: [PATCH] Added timestamp support --- Dockerfile | 1 + README.md | 2 +- backup.sh | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 116bee3..2fc7ee4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ COPY start.sh backup.sh / ENV DB_FILE /data/db.sqlite3 ENV BACKUP_FILE /data/db-backup.sqlite3 ENV CRON_TIME "0 5 * * *" +ENV TIMESTAMP false RUN chmod 700 /start.sh /backup.sh diff --git a/README.md b/README.md index 00161a5..34c06a3 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,4 @@ docker run --rm --volumes-from=bitwarden registry.gitlab.com/1o/bitwarden_rs-bac | DB_FILE | Path to the Bitwarden sqlite3 database | | BACKUP_FILE | Path to the desired backup location | | CRON_TIME | Cronjob format "Minute Hour Day_of_month Month_of_year Day_of_week Year" | - +| TIMESTAMP | Set to `true` to append timestamp to the `BACKUP_FILE` | diff --git a/backup.sh b/backup.sh index e35a5c4..12a69fc 100644 --- a/backup.sh +++ b/backup.sh @@ -1,5 +1,10 @@ #!/bin/sh +if [ $TIMESTAMP = true ] +then + BACKUP_FILE="$(echo $BACKUP_FILE)_$(date "+%F-%H%M%S")" +fi + /usr/bin/sqlite3 $DB_FILE ".backup $BACKUP_FILE" if [ $? -eq 0 ] then