Created
November 19, 2017 20:05
-
-
Save anthonyclarka2/1d19b17aa61d581525d865a150aad588 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
#!/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