Created
June 12, 2022 17:08
-
-
Save athphane/d2d9538e674e43675fecc9f107d9d998 to your computer and use it in GitHub Desktop.
Bash script to zip up Vaultwarden data directory and upload to Cloud storage.
This file contains hidden or 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 | |
#edit these to your config | |
BWDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | |
DATETIME="$(date +'%Y-%m-%d_%H-%M-%S')" | |
FOLDERPATH="$(date +'%Y-%m-%d')" | |
GZFILE=bitwarden-${DATETIME}.tar.gz | |
#change working dir to /tmp | |
cd /tmp/ | |
# Compress Vaultwarden directory to gzfile | |
tar -Pczf $GZFILE $BWDIR | |
# Copy the file to an Rclone storage endpoint | |
rclone copy $GZFILE MyGoogleDrive:/bitwarden_backups/${FOLDERPATH}/ | |
#remove temp file | |
rm $GZFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Above is the script. And to automate this, just add the following line to your Crontab.
0 */3 * * * ~/docker/bitwarden_rs/backup-script.sh
You can adjust your crontab timings as necessary.
In the process of publishing this script I found out that my script had not been backing up since January 2022. Well dang. Had to update the rclone config for the Google Drive mount.