Created
January 20, 2020 15:24
-
-
Save harryf/d23a1ceda84806a099782558fc317adb to your computer and use it in GitHub Desktop.
Quick script for making incremental backups of a keepass database. Combine with Google Drive (or similar) for syncing across devices...
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/sh | |
# Cron job | |
# 15 10 * * * /Users/<username>/bin/backup-passwords | |
# may need some hacks to get crontab running on OSX | |
DIR="$HOME/GoogleDrive/passwords" | |
PASSWDF="$DIR/passwords2.kdbx" | |
BACKUPF="$DIR/passwords2-"$(date "+%Y%m%d")".kdbx" | |
if [ ! -e "$PASSWDF" ] | |
then | |
>2& echo "$PASSWDF not found" | |
exit | |
fi | |
LASTBKF=$(ls -r $DIR/passwords2-????????.kdbx | head -1) | |
DIFF=`diff $PASSWDF $LASTBKF` | |
if [ "$DIFF" != "" ] | |
then | |
cp "$PASSWDF" "$BACKUPF" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gives you files in the
$HOME/GoogleDrive/passwords
directory like this, wherepasswords2.kdbx
is the active database