Skip to content

Instantly share code, notes, and snippets.

@achilleas-k
Created August 31, 2022 17:54
Show Gist options
  • Save achilleas-k/42b1af3c2055fde1ee57a6adbb2a2220 to your computer and use it in GitHub Desktop.
Save achilleas-k/42b1af3c2055fde1ee57a6adbb2a2220 to your computer and use it in GitHub Desktop.
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