Created
January 14, 2021 01:35
-
-
Save gideonshaked/3ee375f9a577517f94ec173f9fd8d090 to your computer and use it in GitHub Desktop.
A bash script to back up bitwarden_rs db and attachments with rclone
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
#!/usr/bin/env bash | |
# | |
################################################################################################################### | |
# Script to back up Bitwarden_rs db and attachments with rclone. Overall, this script should be preferred to | |
# bitwarden-backup.sh because it backs up all users and does not need to be run interactively. | |
# | |
# Note that this script does not encrypt the backup because Bitwarden stores it already encrypted. | |
# | |
# This script is specific to my setup. It had to have some workarounds due to permissions issues and other things. | |
# Please test it before you try it! | |
# | |
# Requirements: | |
# sqlite3 | |
# rclone | |
################################################################################################################### | |
#################### CONFIGURATION #################### | |
# Your rclone remote (can be found with "rclone listremotes") | |
rclone_remote=personal-gdrive | |
# Your rclone destination path (the directory where the backup will be saved) | |
rclone_path=bitwarden-server-backup | |
# The full path to the Bitwarden data directory | |
bw_data=/home/administrator/docker/bitwarden | |
################ END OF CONFIGURATION ################# | |
# Back up db + attachments | |
mkdir backup | |
sqlite3 $bw_data/db.sqlite3 ".backup 'backup/backup.sqlite3'" | |
cp -r $bw_data/attachments backup/attachments | |
# Create an archive | |
tar czf backup.tar.gz backup | |
rm -rf backup/ | |
# Upload | |
sudo -u administrator rclone copy backup.tar.gz "$rclone_remote":"$rclone_path" | |
rm backup.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment