mirror of
https://github.com/xzeldon/vwdump.git
synced 2025-06-28 05:38:16 +03:00
Merge branch '17-suggestion-backup-attachements' into 'dev'
Update Dockerfile, entrypoint.sh, backup.sh files See merge request 1O/bitwarden_rs-backup!6
This commit is contained in:
commit
c89c8f1a00
34
.github/workflows/lockdown.yml
vendored
Normal file
34
.github/workflows/lockdown.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: 'Lock down repository'
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: opened
|
||||||
|
pull_request:
|
||||||
|
types: opened
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lockdown:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: dessant/repo-lockdown@v2
|
||||||
|
with:
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
issue-labels: 'off-topic'
|
||||||
|
issue-comment: >
|
||||||
|
Thanks for your contribution!
|
||||||
|
|
||||||
|
However, this repository does not accept bug reports,
|
||||||
|
since this is only a mirror of
|
||||||
|
https://gitlab.com/1O/bitwarden_rs-backup.
|
||||||
|
|
||||||
|
Please feel free to open the issue there.
|
||||||
|
skip-closed-issue-comment: true
|
||||||
|
pr-comment: >
|
||||||
|
Thanks for your contribution!
|
||||||
|
|
||||||
|
However, this repository does not accept pull requests,
|
||||||
|
since this is only a mirror of
|
||||||
|
https://gitlab.com/1O/bitwarden_rs-backup.
|
||||||
|
|
||||||
|
Please feel free to open the pull request there.
|
||||||
|
skip-closed-pr-comment: true
|
@ -11,6 +11,8 @@ RUN apk add --no-cache \
|
|||||||
|
|
||||||
ENV DB_FILE /data/db.sqlite3
|
ENV DB_FILE /data/db.sqlite3
|
||||||
ENV BACKUP_FILE /data/db_backup/backup.sqlite3
|
ENV BACKUP_FILE /data/db_backup/backup.sqlite3
|
||||||
|
#ENV ATTACHMENT_BACKUP_FILE=/data/attachments_backup/attachments
|
||||||
|
ENV ATTACHMENT_DIR=/data/attachments
|
||||||
ENV BACKUP_FILE_PERMISSIONS 700
|
ENV BACKUP_FILE_PERMISSIONS 700
|
||||||
ENV CRON_TIME "0 5 * * *"
|
ENV CRON_TIME "0 5 * * *"
|
||||||
ENV TIMESTAMP false
|
ENV TIMESTAMP false
|
||||||
|
28
README.md
28
README.md
@ -46,19 +46,21 @@ docker run --rm --volumes-from=bitwarden -e UID=0 -e BACKUP_FILE=/myBackup/backu
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Environment variables
|
## Environment variables
|
||||||
| ENV | Description |
|
| ENV | Description |
|
||||||
| ----------------------- | ------------------------------------------------------------------------ |
|
| ----------------------- | -------------------------------------------------------------------------------------- |
|
||||||
| DB_FILE | Path to the Bitwarden sqlite3 database *inside* the container |
|
| DB_FILE | Path to the Bitwarden sqlite3 database *inside* the container |
|
||||||
| BACKUP_FILE | Path to the desired backup location *inside* the container |
|
| BACKUP_FILE | Path to the desired backup location *inside* the container |
|
||||||
| BACKUP_FILE_PERMISSIONS | Sets the permissions of the backup file (**CAUTION** [^1]) |
|
| BACKUP_FILE_PERMISSIONS | Sets the permissions of the backup file (**CAUTION** [^1]) |
|
||||||
| CRON_TIME | Cronjob format "Minute Hour Day_of_month Month_of_year Day_of_week Year" |
|
| 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` |
|
| TIMESTAMP | Set to `true` to append timestamp to the `BACKUP_FILE` |
|
||||||
| UID | User ID to run the cron job with |
|
| UID | User ID to run the cron job with |
|
||||||
| GID | Group ID to run the cron job with |
|
| GID | Group ID to run the cron job with |
|
||||||
| LOGFILE | Path to the logfile *inside* the container |
|
| LOGFILE | Path to the logfile *inside* the container |
|
||||||
| CRONFILE | Path to the cron file *inside* the container |
|
| CRONFILE | Path to the cron file *inside* the container |
|
||||||
| DELETE_AFTER | Delete old backups after X many days |
|
| DELETE_AFTER | Delete old backups after X many days |
|
||||||
| TZ | Set the timezone inside the container [^2]
|
| TZ | Set the timezone inside the container [^2] |
|
||||||
|
| ATTACHMENT_BACKUP_FILE | If present, the directory `ATTACHMENT_DIR` are backup in path `ATTACHMENT_BACKUP_FILE` |
|
||||||
|
| ATTACHMENT_DIR | Path to the Bitwarden attachement file *inside* the container |
|
||||||
|
|
||||||
[^1]: The permissions should at least be 700 since the backup folder itself gets the same permissions and with 600 it would not be accessible.
|
[^1]: The permissions should at least be 700 since the backup folder itself gets the same permissions and with 600 it would not be accessible.
|
||||||
[^2]: see <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for more information
|
[^2]: see <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for more information
|
||||||
|
25
backup.sh
25
backup.sh
@ -7,13 +7,26 @@ then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Check if ATTACHMENT_BACKUP_FILE exist. If it's true, attechment are backup. We define var with or without TIMESTAMP
|
||||||
|
# In anycase, we define var LOCALVAR_ATTACHMENT_BACKUP_FILE to limit the complexity of code (the number of if-else)
|
||||||
|
if [ ! -z $ATTACHMENT_BACKUP_FILE ]
|
||||||
|
then
|
||||||
|
LOCALVAR_ATTACHMENT_BACKUP_FILE="$ATTACHMENT_BACKUP_FILE"
|
||||||
|
else
|
||||||
|
LOCALVAR_ATTACHMENT_BACKUP_FILE=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $TIMESTAMP = true ]
|
if [ $TIMESTAMP = true ]
|
||||||
then
|
then
|
||||||
FINAL_BACKUP_FILE="$(echo "$BACKUP_FILE")_$(date "+%F-%H%M%S")"
|
FINAL_BACKUP_FILE="$(echo "$BACKUP_FILE")_$(date "+%F-%H%M%S")"
|
||||||
|
FINAL_BACKUP_ATTACHMENT="$(echo "$LOCALVAR_ATTACHMENT_BACKUP_FILE")_$(date "+%F-%H%M%S")"
|
||||||
else
|
else
|
||||||
FINAL_BACKUP_FILE=$BACKUP_FILE
|
FINAL_BACKUP_FILE=$BACKUP_FILE
|
||||||
|
FINAL_BACKUP_ATTACHMENT=$LOCALVAR_ATTACHMENT_BACKUP_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
/usr/bin/sqlite3 $DB_FILE ".backup $FINAL_BACKUP_FILE"
|
/usr/bin/sqlite3 $DB_FILE ".backup $FINAL_BACKUP_FILE"
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
@ -22,7 +35,19 @@ else
|
|||||||
echo "$(date "+%F %T") - Backup unsuccessfull"
|
echo "$(date "+%F %T") - Backup unsuccessfull"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ ! -z $ATTACHMENT_BACKUP_FILE ]
|
||||||
|
then
|
||||||
|
echo "Create tar ${FINAL_BACKUP_ATTACHMENT}.tgz\n"
|
||||||
|
/bin/tar -czf ${FINAL_BACKUP_ATTACHMENT}.tgz ${ATTACHMENT_DIR}
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -z $DELETE_AFTER ] && [ $DELETE_AFTER -gt 0 ]
|
if [ ! -z $DELETE_AFTER ] && [ $DELETE_AFTER -gt 0 ]
|
||||||
then
|
then
|
||||||
find $(dirname "$BACKUP_FILE") -name "$(basename "$BACKUP_FILE")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \;
|
find $(dirname "$BACKUP_FILE") -name "$(basename "$BACKUP_FILE")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \;
|
||||||
|
|
||||||
|
if [ ! -z $ATTACHMENT_BACKUP_FILE ]
|
||||||
|
then
|
||||||
|
find $(dirname "$FINAL_BACKUP_ATTACHMENT") -name "$(basename "$FINAL_BACKUP_ATTACHMENT")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \;
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -15,9 +15,16 @@ then
|
|||||||
install -o $UID -g $GID -m $BACKUP_FILE_PERMISSIONS -d $BACKUP_DIR
|
install -o $UID -g $GID -m $BACKUP_FILE_PERMISSIONS -d $BACKUP_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ATTACHMENT_BACKUP_DIR=$(dirname "$ATTACHMENT_BACKUP_FILE")
|
||||||
|
if [ ! -d "$ATTACHMENT_BACKUP_DIR" ]
|
||||||
|
then
|
||||||
|
echo "$ATTACHMENT_BACKUP_DIR not exists. Creating it with owner $UID:$GID and permissions $BACKUP_FILE_PERMISSIONS."
|
||||||
|
install -o $UID -g $GID -m $BACKUP_FILE_PERMISSIONS -d $ATTACHMENT_BACKUP_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
# For compatibility reasons
|
# For compatibility reasons
|
||||||
if [ "$1" = "/backup.sh" ]; then
|
if [ "$1" = "/backup.sh" ]; then
|
||||||
>&2 echo "Using /backup.sh is deprecated and will be removed in future versions! Please use \`manual\` as arugment instead"
|
>&2 echo "Using /backup.sh is deprecated and will be removed in future versions! Please use \`manual\` as argument instead"
|
||||||
$BACKUP_CMD
|
$BACKUP_CMD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user