mirror of
https://github.com/xzeldon/vwdump.git
synced 2025-06-28 01:48:14 +03:00
Modify script.sh to not error when files missing from vw data vol (#30)
This commit is contained in:
parent
10fa458b10
commit
38dbb2d66d
@ -43,6 +43,12 @@ services:
|
|||||||
|
|
||||||
`/backups` _(write)_ - Where to store backups to.
|
`/backups` _(write)_ - Where to store backups to.
|
||||||
|
|
||||||
|
User specified in compose environment (`UID`/`GID`) vars must have write access to `/backups`
|
||||||
|
If you want to make them the owner of the backups directory do:
|
||||||
|
```
|
||||||
|
chown ${UID}:${GID} /path/to/backups
|
||||||
|
```
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
#### ⭐Required, 👍 Recommended
|
#### ⭐Required, 👍 Recommended
|
||||||
| Environment Variable | Info |
|
| Environment Variable | Info |
|
||||||
|
35
script.sh
35
script.sh
@ -7,8 +7,7 @@ EXTENSION="tar.xz"
|
|||||||
|
|
||||||
# ------------------ [ BACKUP ] ------------------
|
# ------------------ [ BACKUP ] ------------------
|
||||||
|
|
||||||
cd /data
|
cd /data || exit 1 # Exit with error if opening vw data file fails
|
||||||
|
|
||||||
BACKUP_LOCATION="/backups/$(date +"%F_%H-%M-%S").${EXTENSION}"
|
BACKUP_LOCATION="/backups/$(date +"%F_%H-%M-%S").${EXTENSION}"
|
||||||
|
|
||||||
BACKUP_DB="db.sqlite3" # file
|
BACKUP_DB="db.sqlite3" # file
|
||||||
@ -17,10 +16,36 @@ BACKUP_CONFIG="config.json" # file
|
|||||||
BACKUP_ATTACHMENTS="attachments" # directory
|
BACKUP_ATTACHMENTS="attachments" # directory
|
||||||
BACKUP_SENDS="sends" # directory
|
BACKUP_SENDS="sends" # directory
|
||||||
|
|
||||||
# Back up files and folders.
|
# Create list of backup items to archive
|
||||||
tar -Jcf $BACKUP_LOCATION $BACKUP_DB $BACKUP_RSA $BACKUP_CONFIG $BACKUP_ATTACHMENTS $BACKUP_SENDS 2>/dev/null
|
BACKUP_ITEMS="$BACKUP_DB $BACKUP_RSA $BACKUP_CONFIG $BACKUP_ATTACHMENTS $BACKUP_SENDS"
|
||||||
|
|
||||||
|
# Verify which items are available to be backed up
|
||||||
|
FILES_TO_BACKUP=""
|
||||||
|
WARNING=""
|
||||||
|
|
||||||
|
for ITEM in $BACKUP_ITEMS; do
|
||||||
|
if [ -e "$ITEM" ] || [ -d "$ITEM" ]; then
|
||||||
|
FILES_TO_BACKUP="$FILES_TO_BACKUP $ITEM"
|
||||||
|
else # if an item is missing, raise warning
|
||||||
|
WARNING="$WARNING $ITEM"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print the warnings out in the docker logs
|
||||||
|
if [ -n "$WARNING" ]; then
|
||||||
|
echo "[WARNING] The following expected files/directories are missing:$WARNING" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Back up files and folders, only if there are files to back up
|
||||||
|
if [ -n "$FILES_TO_BACKUP" ]; then
|
||||||
|
echo "[INFO] Backing up:$FILES_TO_BACKUP"
|
||||||
|
tar -Jcf "$BACKUP_LOCATION" $FILES_TO_BACKUP
|
||||||
|
OUTPUT="New backup created"
|
||||||
|
else
|
||||||
|
OUTPUT="No files to back up"
|
||||||
|
fi
|
||||||
|
|
||||||
OUTPUT="${OUTPUT}New backup created"
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------ [ DELETE ] ------------------
|
# ------------------ [ DELETE ] ------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user