From e551725d7aa82017bbc3b92020e5ca8fcadb1967 Mon Sep 17 00:00:00 2001 From: 10 <10@users.noreply.gitlab.com> Date: Sun, 18 Nov 2018 02:14:19 +0100 Subject: [PATCH 1/2] Changed time format --- backup.sh | 4 ++-- start.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backup.sh b/backup.sh index c4843e8..e35a5c4 100644 --- a/backup.sh +++ b/backup.sh @@ -3,7 +3,7 @@ /usr/bin/sqlite3 $DB_FILE ".backup $BACKUP_FILE" if [ $? -eq 0 ] then - echo "$(date) - Backup successfull" + echo "$(date "+%F %T") - Backup successfull" else - echo "$(date) - Backup unsuccessfull" + echo "$(date "+%F %T") - Backup unsuccessfull" fi diff --git a/start.sh b/start.sh index c3c9e17..d465a1b 100644 --- a/start.sh +++ b/start.sh @@ -24,5 +24,5 @@ then /usr/sbin/crond -L /var/log/cron.log fi -echo "$(date) - Container started" > "$LOGFILE" +echo "$(date "+%F %T") - Container started" > "$LOGFILE" tail -F "$LOGFILE" 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 2/2] 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