vuls: init at 0.27.0
[NixPkgs.git] / nixos / modules / services / security / vaultwarden / backup.sh
blob0c1cd3aa544f60a8d4d4d83e0e07ee8af64311b6
1 #!/usr/bin/env bash
3 # Allow use of !() when copying to not copy certain files
4 shopt -s extglob
6 # Based on: https://github.com/dani-garcia/vaultwarden/wiki/Backing-up-your-vault
7 if [ ! -d "$BACKUP_FOLDER" ]; then
8 echo "Backup folder '$BACKUP_FOLDER' does not exist" >&2
9 exit 1
12 if [[ -f "$DATA_FOLDER"/db.sqlite3 ]]; then
13 sqlite3 "$DATA_FOLDER"/db.sqlite3 ".backup '$BACKUP_FOLDER/db.sqlite3'"
16 if [ ! -d "$DATA_FOLDER" ]; then
17 echo "No data folder (yet). This will happen on first launch if backup is triggered before vaultwarden has started."
18 exit 0
21 cp -r "$DATA_FOLDER"/!(db.*) "$BACKUP_FOLDER"/