2020-04-24 23:36:52 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-07-01 15:47:52 +00:00
|
|
|
# Allow use of !() when copying to not copy certain files
|
|
|
|
shopt -s extglob
|
|
|
|
|
2021-07-04 02:40:35 +00:00
|
|
|
# Based on: https://github.com/dani-garcia/vaultwarden/wiki/Backing-up-your-vault
|
2024-01-13 08:15:51 +00:00
|
|
|
if [ ! -d "$BACKUP_FOLDER" ]; then
|
|
|
|
echo "Backup folder '$BACKUP_FOLDER' does not exist" >&2
|
2020-04-24 23:36:52 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-07-01 15:47:52 +00:00
|
|
|
if [[ -f "$DATA_FOLDER"/db.sqlite3 ]]; then
|
|
|
|
sqlite3 "$DATA_FOLDER"/db.sqlite3 ".backup '$BACKUP_FOLDER/db.sqlite3'"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$DATA_FOLDER" ]; then
|
|
|
|
echo "No data folder (yet). This will happen on first launch if backup is triggered before vaultwarden has started."
|
|
|
|
exit 0
|
2020-04-24 23:36:52 +00:00
|
|
|
fi
|
|
|
|
|
2024-07-01 15:47:52 +00:00
|
|
|
cp -r "$DATA_FOLDER"/!(db.*) "$BACKUP_FOLDER"/
|