mirror of
https://github.com/xzeldon/vwdump.git
synced 2025-06-28 06:58:15 +03:00
parent
3f0bd862f7
commit
51889d3be3
@ -9,7 +9,7 @@ RUN apk add --no-cache \
|
||||
|
||||
ENV DB_FILE /data/db.sqlite3
|
||||
ENV BACKUP_FILE /data/db_backup/backup.sqlite3
|
||||
ENV BACKUP_FILE_PERMISSIONS 600
|
||||
ENV BACKUP_FILE_PERMISSIONS 700
|
||||
ENV CRON_TIME "0 5 * * *"
|
||||
ENV TIMESTAMP false
|
||||
ENV UID 100
|
||||
|
@ -44,7 +44,7 @@ docker run --rm --volumes-from=bitwarden -v /tmp/myBackup:/myBackup --entrypoint
|
||||
| ----- | ----- |
|
||||
| DB_FILE | Path to the Bitwarden sqlite3 database *inside* the container |
|
||||
| BACKUP_FILE | Path to the desired backup location *inside* the container |
|
||||
| BACKUP_FILE_PERMISSIONS | Sets the permissions of the backup file |
|
||||
| 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" |
|
||||
| TIMESTAMP | Set to `true` to append timestamp to the `BACKUP_FILE` |
|
||||
| UID | User ID to run the cron job with |
|
||||
@ -53,6 +53,8 @@ docker run --rm --volumes-from=bitwarden -v /tmp/myBackup:/myBackup --entrypoint
|
||||
| CRONFILE | Path to the cron file *inside* the container |
|
||||
| DELETE_AFTER | Delete old backups after X many days |
|
||||
|
||||
[^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.
|
||||
|
||||
## Common erros
|
||||
### Wrong permissions
|
||||
`Error: unable to open database file` is most likely caused by permission errors.
|
||||
|
@ -5,12 +5,14 @@
|
||||
|
||||
BACKUP_CMD="/sbin/su-exec ${UID}:${GID} /app/backup.sh"
|
||||
|
||||
echo "Running $(basename "$0") as $(id)"
|
||||
|
||||
# Preparation
|
||||
if [ ! -d $(dirname "$BACKUP_FILE") ]
|
||||
BACKUP_DIR=$(dirname "$BACKUP_FILE")
|
||||
if [ ! -d "$BACKUP_DIR" ]
|
||||
then
|
||||
mkdir -p $(dirname "$BACKUP_FILE")
|
||||
chown -R $UID:$GID $(dirname "$BACKUP_FILE")
|
||||
chmod -R "$BACKUP_FILE_PERMISSIONS" $(dirname "$BACKUP_FILE")
|
||||
echo "$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 $BACKUP_DIR
|
||||
fi
|
||||
|
||||
# For compatibility reasons
|
||||
@ -25,9 +27,9 @@ if [ "$1" = "manual" ]; then
|
||||
fi
|
||||
|
||||
# Initialize cron
|
||||
echo "Running as $(id)"
|
||||
if [ "$(id -u)" -eq 0 ] && [ "$(grep -c "$BACKUP_CMD" "$CRONFILE")" -eq 0 ]; then
|
||||
echo "Initalizing..."
|
||||
echo "Writing backup command \"$BACKUP_CMD\" to cron."
|
||||
echo "$CRON_TIME $BACKUP_CMD >> $LOGFILE 2>&1" | crontab -
|
||||
|
||||
fi
|
||||
@ -40,6 +42,7 @@ fi
|
||||
|
||||
# Restart script as user "app:app"
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
echo "Restarting $(basename "$0") as app:app"
|
||||
exec su-exec app:app "$0" "$@"
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user