summaryrefslogtreecommitdiff
path: root/lastBackups.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-05-04 10:20:42 +0200
committerErich Eckner <git@eckner.net>2016-05-04 10:20:42 +0200
commite63bf65b3661e582a2a6b42b131c3a53f04108a4 (patch)
tree2247570e88f487dc5bd3d08dfd335cce565490ce /lastBackups.in
parent930ced0b96e4b0ac32eadf1037c1c3e78e3988ec (diff)
downloadhardlinkedBackups-e63bf65b3661e582a2a6b42b131c3a53f04108a4.tar.xz
Makefile, manpage neu, neue Version
Diffstat (limited to 'lastBackups.in')
-rwxr-xr-xlastBackups.in73
1 files changed, 73 insertions, 0 deletions
diff --git a/lastBackups.in b/lastBackups.in
new file mode 100755
index 0000000..ea6040a
--- /dev/null
+++ b/lastBackups.in
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+# lastBackups version #VERSION#
+
+. #ETCDIR#/backup.conf
+
+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\$##"))"
+ [ ! "$(ls -A ${dest}/${lbu})" ] &&
+ veraltet[${#veraltet[@]}]="LEER!" ||
+ [ ${delta} -gt ${outdatedLimit} ] && \
+ veraltet[${#veraltet[@]}]="VERALTET!" || \
+ veraltet[${#veraltet[@]}]=""
+ 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//"