Created
September 8, 2025 15:33
-
-
Save hiAndrewQuinn/1a0c019a76fdabbf0e6edb2e68ba5a47 to your computer and use it in GitHub Desktop.
POSIX shell script for hourly backups of a KeePass database to tarsnap. Season to taste.
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/sh | |
| set -e | |
| KEYFILE="$HOME/.tarsnap.key" | |
| CACHEDIR="$HOME/.tarsnap-cache" | |
| SOURCE_FILE="$HOME/Documents/Passwords.kdbx" # or wherever it is | |
| HOSTNAME=$(/usr/bin/hostname) | |
| BASENAME=$(/usr/bin/basename "$SOURCE_FILE") | |
| TIMESTAMP=$(/usr/bin/date +"%Y-%m-%d_%H-%M-%S") | |
| ARCHIVE_NAME="${HOSTNAME}-${BASENAME}-${TIMESTAMP}" | |
| /usr/bin/date --iso-8601=seconds | |
| /usr/bin/tarsnap -c \ | |
| --keyfile "$KEYFILE" \ | |
| --cachedir "$CACHEDIR" \ | |
| -f "$ARCHIVE_NAME" \ | |
| --print-stats \ | |
| --humanize-numbers \ | |
| "$SOURCE_FILE" | |
| /usr/bin/echo "---" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment