Skip to content

Instantly share code, notes, and snippets.

@hxueh
Last active March 29, 2020 09:18
Show Gist options
  • Save hxueh/b72ccdd832be538eafa684c65e0de87e to your computer and use it in GitHub Desktop.
Save hxueh/b72ccdd832be538eafa684c65e0de87e to your computer and use it in GitHub Desktop.
#!/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