This script can be added to your bash startup script in order to remind you to do weekly / daily backups.
Last active
August 1, 2017 00:25
-
-
Save stv0g/79b27c52149f98104ea6c0cab3628f9a to your computer and use it in GitHub Desktop.
Check if a new backup should be triggered
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 | |
export RESTIC_PASSWORD=$(pass restic) | |
TIMESPAN="1 week ago" | |
DIR="/Users/stv0g" | |
ATLEAST=$(date --iso-8601=ns --date "${TIMESPAN}") | |
ALL=$(restic snapshots --json) | |
LAST=$(echo "${ALL}" | jq -r "map(select(.paths[] | contains (\"${DIR}\"))) | sort_by(.time) | .[1]") | |
TIME=$(echo "${LAST}" | jq -r ".time") | |
if [[ "${TIME}" < "${ATLEAST}" ]]; then | |
echo "You should to do a backup!" | |
echo "Last backup of ${DIR} was made on ${TIME} which is more than ${TIMESPAN}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment