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

Add support for sends folder (#1)

* Add sends backup

* Add send

* Add docs for send
This commit is contained in:
jmqm 2021-05-25 16:55:22 -05:00 committed by GitHub
parent 762026a5ad
commit df32ec66f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -23,6 +23,11 @@ Example for backup including attachment folder (see [Environment variables secti
docker run -d --restart=always --name bitwarden_backup --volumes-from=bitwarden -e ATTACHMENT_BACKUP_FILE=/data/attachments_backup/attachments bruceforce/bw_backup
```
Example for backup including send folder (see [Environment variables section](#environment-variables) for more information)
```sh
docker run -d --restart=always --name bitwarden_backup --volumes-from=bitwarden -e SEND_BACKUP_FILE=/data/sends_backup/sends bruceforce/bw_backup
```
Example for hourly backups
```sh
docker run -d --restart=always --name bitwarden_backup --volumes-from=bitwarden -e CRON_TIME="0 * * * *" bruceforce/bw_backup
@ -65,7 +70,9 @@ docker run --rm --volumes-from=bitwarden -e UID=0 -e BACKUP_FILE=/myBackup/backu
| DELETE_AFTER | Delete old backups after X many days |
| 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 |
| ATTACHMENT_DIR | Path to the Bitwarden attachment folder *inside* the container |
| SEND_BACKUP_FILE | If present, the directory `SEND_DIR` are backup in path `SEND_BACKUP_FILE` |
| SEND_DIR | Path to the Bitwarden send folder *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.
[^2]: see <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> for more information

View File

@ -17,13 +17,24 @@ else
LOCALVAR_ATTACHMENT_BACKUP_FILE=""
fi
# Check if SEND_BACKUP_FILE exist. If it's true, attechment are backup. We define var with or without TIMESTAMP
# In anycase, we define var LOCALVAR_SEND_BACKUP_FILE to limit the complexity of code (the number of if-else)
if [ ! -z $SEND_BACKUP_FILE ]
then
LOCALVAR_SEND_BACKUP_FILE="$SEND_BACKUP_FILE"
else
LOCALVAR_SEND_BACKUP_FILE=""
fi
if [ $TIMESTAMP = true ]
then
FINAL_BACKUP_FILE="$(echo "$BACKUP_FILE")_$(date "+%F-%H%M%S")"
FINAL_BACKUP_ATTACHMENT="$(echo "$LOCALVAR_ATTACHMENT_BACKUP_FILE")_$(date "+%F-%H%M%S")"
FINAL_BACKUP_SEND="$(echo "$LOCALVAR_SEND_BACKUP_FILE")_$(date "+%F-%H%M%S")"
else
FINAL_BACKUP_FILE=$BACKUP_FILE
FINAL_BACKUP_ATTACHMENT=$LOCALVAR_ATTACHMENT_BACKUP_FILE
FINAL_BACKUP_SEND=$LOCALVAR_SEND_BACKUP_FILE
fi
@ -42,6 +53,12 @@ then
/bin/tar -czf ${FINAL_BACKUP_ATTACHMENT}.tgz ${ATTACHMENT_DIR}
fi
if [ ! -z $SEND_BACKUP_FILE ]
then
echo "Create tar ${FINAL_BACKUP_SEND}.tgz\n"
/bin/tar -czf ${FINAL_BACKUP_SEND}.tgz ${SEND_DIR}
fi
if [ ! -z $DELETE_AFTER ] && [ $DELETE_AFTER -gt 0 ]
then
find $(dirname "$BACKUP_FILE") -name "$(basename "$BACKUP_FILE")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \;
@ -50,4 +67,9 @@ then
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
if [ ! -z $SEND_BACKUP_FILE ]
then
find $(dirname "$FINAL_BACKUP_SEND") -name "$(basename "$FINAL_BACKUP_SEND")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \;
fi
fi

View File

@ -22,6 +22,13 @@ then
install -o $UID -g $GID -m $BACKUP_FILE_PERMISSIONS -d $ATTACHMENT_BACKUP_DIR
fi
SEND_BACKUP_DIR=$(dirname "$SEND_BACKUP_FILE")
if [ ! -d "$SEND_BACKUP_DIR" ]
then
echo "$SEND_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 $SEND_BACKUP_DIR
fi
# For compatibility reasons
if [ "$1" = "/backup.sh" ]; then
>&2 echo "Using /backup.sh is deprecated and will be removed in future versions! Please use \`manual\` as argument instead"