Created
August 31, 2022 17:54
-
-
Save achilleas-k/42b1af3c2055fde1ee57a6adbb2a2220 to your computer and use it in GitHub Desktop.
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
timesince() { | |
local now | |
local last_ts | |
local last | |
now=$(date +%s) | |
last_ts="$(borg list -P "${destprefix}" --json | jq -r '.archives[-1].time')" | |
last=$(date -d "${last_ts}" +%s) | |
echo $(( now - last )) | |
} | |
min_interval=21600 # 6 hours | |
interval=$(timesince) | |
if (( interval < min_interval )); then | |
echo "Last backup ${interval} secs ago. Aborting." | |
exit 0 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment