Skip to content

Instantly share code, notes, and snippets.

@anthonyclarka2
Created November 19, 2017 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyclarka2/1d19b17aa61d581525d865a150aad588 to your computer and use it in GitHub Desktop.
Save anthonyclarka2/1d19b17aa61d581525d865a150aad588 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Creates a simple dokuwiki page, listing Borg backups from a text file
# File has one entry per line: "host.example.net-2017-08-31-02:55 Thu, 2017-08-31 02:55:03"
# Runs in cron early every morning: list-backups.sh host.example.net.txt > dokuwikipage.txt
BACKUP_LIST=$1
HOST_NAME=$(basename -s .txt "${BACKUP_LIST}")
echo "====== ${HOST_NAME} Backup List ======"
echo
while IFS= read -r BACKUP_LINE
do
BACKUP_DATE=$(echo "${BACKUP_LINE}" | sed -n '/^.*-\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\).*/s//\1/p')
BACKUP_TIME=$(echo "${BACKUP_LINE}" | sed -n '/.* \([0-9]\{2\}:[0-9]\{2\}\):[0-9]\{2\}$/s//\1/p')
echo " * ${BACKUP_DATE} at ${BACKUP_TIME}"
done < <(cat "${BACKUP_LIST}")
echo
echo "----"
echo "Go back to [[IT::Backups::start|Backup List]]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment