Last active
April 7, 2021 08:52
-
-
Save janlay/540dd5da1f914cce763af90981fa1ba7 to your computer and use it in GitHub Desktop.
Backup Bitwarden Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Backup db and certs in $BITWARDEN_DIR into $TARGET_DIR/$FILENAME_PREFIX$DATE.tar.gz | |
BITWARDEN_DIR='/volume1/docker/Bitwarden' | |
TARGET_DIR='/var/services/dropbox/Backup/Bitwarden' | |
FILENAME_PREFIX='bw-backup_' | |
FILENAME_DATE_PATTERN='%m-%d' | |
TEMP_DIR=$(mktemp -d) | |
cleanup() { | |
rm -rf "$TEMP_DIR" | |
} | |
main() { | |
# backup db | |
sqlite3 "$BITWARDEN_DIR/db.sqlite3" ".backup '$TEMP_DIR/db.sqlite3'" | |
# backup certs | |
cp "$BITWARDEN_DIR"/rsa_* "$TEMP_DIR" | |
# pack files | |
local backup_file="$TARGET_DIR/$FILENAME_PREFIX$(date +"$FILENAME_DATE_PATTERN").tar.gz" | |
tar -czf "$backup_file" -C "$TEMP_DIR" . | |
} | |
trap cleanup EXIT | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment