Skip to content

Instantly share code, notes, and snippets.

@hxueh hxueh/backup_ledger.sh
Last active Mar 29, 2020

Embed
What would you like to do?
#!/usr/bin/env sh
LEDGER_DIR="/path/to/directory"
LEDGER_NAME="Ledger"
GPG_PUB_KEY="YOURGPGFINGERPRINT"
NOW=$($(which date) --iso-8601=seconds)
CURRENT_MONTH=$($(which date) +%Y-%m)
BACKBLAZE_BUCKET="YOURBUCKETNAME"
BACKBLAZE_REMOTE_FILE_DIR="Ledger"
$(which tar) --exclude=".vscode" --exclude=".git" --create --directory $LEDGER_DIR $LEDGER_NAME | $(which gzip) --best | $(which gpg) --encrypt --recipient $GPG_PUB_KEY --output /tmp/$LEDGER_NAME.$NOW.tgz.gpg
$(which b2) upload-file $BACKBLAZE_BUCKET /tmp/$LEDGER_NAME.$NOW.tgz.gpg $BACKBLAZE_REMOTE_FILE_DIR/$CURRENT_MONTH/$LEDGER_NAME.$NOW.tgz.gpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.