Created
March 26, 2023 11:28
-
-
Save zekroTJA/ad14bfbfe9d736d4e41c18eb87da0cf8 to your computer and use it in GitHub Desktop.
VaultWarden backup script
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 | |
DATA_DIR="<BITWARDEN DATA PATH>" | |
REPO_URL="[email protected]:<REPO>" | |
BRANCH="main" | |
TMP_DIR="/tmp/vault_backup" | |
export GIT_AUTHOR_NAME="vault_backup" | |
export GIT_AUTHOR_EMAIL="[email protected]" | |
# ---------------------------------------------------- | |
function gitc { | |
git -C $TMP_DIR $@ | |
} | |
set -ex | |
[ -d $TMP_DIR ] && rm -rf $TMP_DIR | |
[ ! -d $TMP_DIR ] && mkdir -p $TMP_DIR | |
gitc init | |
gitc checkout -b $BRANCH | |
gitc remote add origin $REPO_URL | |
gitc pull origin $BRANCH || true | |
tar czf $TMP_DIR/data.tar.gz -C $DATA_DIR . | |
gitc add data.tar.gz | |
gitc commit -m "update-backup" | |
gitc push origin $BRANCH | |
rm -rf $TMP_DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment