1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-06-28 03:08:14 +03:00

initial commit

This commit is contained in:
10 2018-11-16 01:39:51 +01:00
commit bd9987a124
5 changed files with 97 additions and 0 deletions

23
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,23 @@
tages:
- build:docker
variables:
IMAGE_NAME: "$CI_REGISTRY_IMAGE/bw_backup"
.docker_login: &docker_login
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
.docker_build_template: &docker_build
stage: build:docker
image: docker:latest
services:
- docker:dind
tags:
- shared
build:
<<: *docker_build
script:
- *docker_login
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM alpine:latest
RUN apk add --update \
sqlite
COPY start.sh backup.sh /
ENV DB_FILE /data/db.sqlite3
ENV BACKUP_FILE /data/db-backup.sqlite3
ENV CRON_TIME "* * * * *"
RUN chmod 700 /start.sh /backup.sh
CMD /start.sh

22
README.md Normal file
View File

@ -0,0 +1,22 @@
# bitwarden_rs Backup
---
Docker Containers for bitwarden_rs Backup.
## Usage
```sh
docker run --name bitwarden_backup --volumes-from=bitwarden registry.gitlab.com/1o/bitwarden_rs-backup:bw-backup
```
Example for hourly backups
```
docker run --name bitwarden_backup --volumes-from=bitwarden -e CRON_TIME="0 * * * *" registry.gitlab.com/1o/bitwarden_rs-backup:bw-backup
```
## Environment variables
| ENV | Description |
| ----- | ----- |
| 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" |

9
backup.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/sh
/usr/bin/sqlite3 $DB_FILE ".backup $BACKUP_FILE"
if [ $? -eq 0 ]
then
echo "$(date) - Backup successfull"
else
echo "$(date) - Backup unsuccessfull"
fi

28
start.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/sh
DB_FILE=$DB_FILE
BACKUP_FILE=$BACKUP_FILE
CRON_TIME=$CRON_TIME
BACKUP_CMD=/backup.sh #'/usr/bin/sqlite3 '"$DB_FILE"' ".backup '"$BACKUP_FILE"'"'
CRONFILE=/etc/crontabs/root
LOGFILE=/var/log/backup.log
if [ ! -e "$DB_FILE" ]
then
echo "Database $DB_FILE not found!\nPlease check if you mounted the bitwarden_rs volume with '--volumes-from=bitwarden'"!
exit 1;
fi
if [ $(grep -c "$BACKUP_CMD" "$CRONFILE") -eq 0 ]
then
echo "$CRON_TIME $BACKUP_CMD >> $LOGFILE" >> "$CRONFILE"
fi
pgrep crond > /dev/null 2>&1
if [ $? -ne 0 ]
then
/usr/sbin/crond -L /var/log/cron.log
fi
echo "$(date) - Container started" > "$LOGFILE"
tail -F "$LOGFILE"