mirror of
https://github.com/xzeldon/vwdump.git
synced 2025-06-28 04:58:16 +03:00
Check ATTACHMENT_BACKUP_FILE define 🔬
This commit is contained in:
parent
a86966bbe9
commit
2ddc097df5
@ -11,7 +11,7 @@ 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_BACKUP_FILE=/data/attachments_backup/attachments
|
||||||
ENV ATTACHMENT_DIR=/data/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 * * *"
|
||||||
|
@ -47,7 +47,7 @@ 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]) |
|
||||||
@ -58,7 +58,9 @@ docker run --rm --volumes-from=bitwarden -e UID=0 -e BACKUP_FILE=/myBackup/backu
|
|||||||
| 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
|
||||||
|
26
backup.sh
26
backup.sh
@ -7,13 +7,23 @@ then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Chef 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)
|
||||||
|
LOCALVAR_ATTACHMENT_BACKUP_FILE = ""
|
||||||
|
if [ -v ATTACHMENT_BACKUP_FILE ]
|
||||||
|
then
|
||||||
|
LOCALVAR_ATTACHMENT_BACKUP_FILE = ${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 "$ATTACHMENT_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=$ATTACHMENT_BACKUP_FILE
|
FINAL_BACKUP_ATTACHMENT=$LOCALVAR_ATTACHMENT_BACKUP_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -25,10 +35,18 @@ else
|
|||||||
echo "$(date "+%F %T") - Backup unsuccessfull"
|
echo "$(date "+%F %T") - Backup unsuccessfull"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/bin/tar -cvzf ${FINAL_BACKUP_ATTACHMENT}.tgz ${ATTACHMENT_DIR}
|
|
||||||
|
if [ -v ATTACHMENT_BACKUP_FILE ]
|
||||||
|
then
|
||||||
|
/bin/tar -cvzf ${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" \;
|
||||||
find $(dirname "$ATTACHMENT_BACKUP_FILE") -name "$(basename "$ATTACHMENT_BACKUP_FILE")*" -type f -mtime +$DELETE_AFTER -exec rm -f {} \; -exec echo "Deleted {} after $DELETE_AFTER days" \;
|
|
||||||
|
if [ -v 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user