diff options
author | Erich Eckner <git@eckner.net> | 2019-02-10 22:36:04 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-02-10 22:36:04 +0100 |
commit | 314ad8d94c5ff33fd2eadb1027748550be0e7e4f (patch) | |
tree | b94d525ac5758380cbc8cbcc8bce8e5b68823697 /last-backups.in | |
parent | 080efe8cbf8e5bc69a17f8af8f5feffd01dd67fe (diff) | |
download | hardlinkedBackups-314ad8d94c5ff33fd2eadb1027748550be0e7e4f.tar.xz |
camelCase -> no-camel-case, backup-progress new
Diffstat (limited to 'last-backups.in')
-rwxr-xr-x | last-backups.in | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/last-backups.in b/last-backups.in new file mode 100755 index 0000000..a8ee5f2 --- /dev/null +++ b/last-backups.in @@ -0,0 +1,110 @@ +#!/bin/bash + +# last-backups version #VERSION# + +[ -r "#ETCDIR#/backup.conf" ] && \ + . "#ETCDIR#/backup.conf" + +usage () { + >&2 echo \ +'Usage: last-backups +Show information about date of last backups and warn about outdated ones. + +Options: +#HELPTEXT# #' + [ -n "$1" ] && exit $1 + exit 1 +} + +if [ $# -eq 1 ] +then + if [ "$1" == "--help" ] + then + usage 0 + elif [ "$1" == "--version" ] + then + >&2 echo '#VERSION#' + exit 0 + fi + usage +elif [ $# -gt 1 ] +then + usage +fi + +unset namen +unset veraltet +unset daten + +for backupID in ${!backups[@]} +do + dest="${backups["${backupID}"]%% *}" + dest="${dest%/}" + while [ ! -d "${dest}" ] && [ ${maxWait} -gt 0 ] + do + sleep 1 + maxWait=$[${maxWait}-1] + done + + lbu=$( + ls -1 ${dest} | \ + grep -v "^aktuell$" | \ + sed "s/^duplicity-\(inc\|full\)\.\(.*\.\)\?\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)T[0-9]\{6\}Z\..*$/\3_\4_\5/" | \ + sort -n | \ + uniq | \ + grep "^[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}$" | \ + tail -n1 + ) + [ "${lbu}" == "" ] && lbu="2000_01_01" + delta=$[$(date +%s) - $(date -d $(echo ${lbu} | sed "s/_//g") +%s)] + namen[${#namen[@]}]="$(basename $(echo ${dest} | sed "s#/\(${recognSubdirRegex}\)\$#_\1#" | sed "s#/rsync\$##; s#/duplicity\$##"))" + if [ ! -d "${dest}/${lbu}" ] + then + veraltet[${#veraltet[@]}]="LEER!" + elif [ ${delta} -gt ${outdatedLimit} ] && \ + ! printf '%s\n' "${seldomBackups[@]}" | \ + grep -qxF "${backupID}" + then + veraltet[${#veraltet[@]}]="VERALTET!" + elif [ ${delta} -gt ${outdatedSeldomLimit} ] + then + veraltet[${#veraltet[@]}]="VERALTET!" + else + veraltet[${#veraltet[@]}]="" + fi + daten[${#daten[@]}]="${lbu}" +done + +nl=0 +vl=0 +dl=0 + +for ((i=0; i<${#namen[@]}; i++)) +{ + [ ${#namen[${i}]} -gt ${nl} ] && nl=${#namen[${i}]} + [ ${#veraltet[${i}]} -gt ${vl} ] && vl=${#veraltet[${i}]} + [ ${#daten[${i}]} -gt ${dl} ] && dl=${#daten[${i}]} +} + +for ((i=0; i<${#namen[@]}; i++)) +{ + while [ ${#namen[${i}]} -lt ${nl} ] + do + namen[${i}]="${namen[${i}]} " + done + while [ ${#veraltet[${i}]} -lt ${vl} ] + do + veraltet[${i}]="${veraltet[${i}]} " + done + while [ ${#daten[${i}]} -lt ${dl} ] + do + daten[${i}]="${daten[${i}]} " + done +} + +for ((i=0; i<${#namen[@]}; i++)) +{ + echo "${daten[${i}]} ${veraltet[${i}]} ${namen[${i}]} ${daten[${i}]}" +} | \ + sort | \ + sed "s/^\S\+\s//" |