#1 Vaultwarden backup script
This commit is contained in:
parent
85f007a4ee
commit
c07961a4c8
1 changed files with 26 additions and 0 deletions
26
backups/create_vaultwarden_backup.sh
Executable file
26
backups/create_vaultwarden_backup.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
# Backup script for Vaultwarden in a kubernetes cluster
|
||||
|
||||
BACKUP_DEST="/mnt/PRIVATE_DOCS/BACKUPS/vaultwarden"
|
||||
PASSFILE=./vaultwarden_pass.txt
|
||||
|
||||
# Retrieve container names
|
||||
base_container=$( docker ps --format "{{.Names}}" | grep vaultwarden_vaultwarden )
|
||||
database_container=$( docker ps --format "{{.Names}}" | grep vaultwarden-postgresql_vaultwarden-postgresql )
|
||||
|
||||
# Abort entire script if any command fails
|
||||
set -e
|
||||
|
||||
# Database backup
|
||||
>&2 echo "Backing up database"
|
||||
docker exec --env-file "${PASSFILE}" "${database_container}" pg_dump "vaultwarden" -cwv -h "localhost" -U "vaultwarden" -f /tmp/vaultwarden-sqlbkp_`date +"%Y%m%d"`.bak
|
||||
docker cp "${database_container}":/tmp/vaultwarden-sqlbkp_$(date +"%Y%m%d").bak "${BACKUP_DEST}"
|
||||
|
||||
# Files backup
|
||||
files=("attachments" "sends" "config.json" "rsa_key.pem" "rsa_key.pub.pem")
|
||||
for file in "${files[@]}"; do
|
||||
>&2 echo "Copying ${file}"
|
||||
docker cp -a "${base_container}":"/data/${file}" "${BACKUP_DEST}"
|
||||
done
|
||||
|
||||
>&2 echo "Done"
|
Loading…
Reference in a new issue