diff options
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rwxr-xr-x | backup-progress.in | 30 | ||||
-rw-r--r-- | backup-statistics.in (renamed from backupStatistics.in) | 4 | ||||
-rw-r--r-- | backup.conf | 4 | ||||
-rwxr-xr-x | check-diff (renamed from checkDiff) | 0 | ||||
-rw-r--r-- | fast-repair.in (renamed from fastRepair.in) | 2 | ||||
-rwxr-xr-x | last-backups.in (renamed from lastBackups.in) | 4 | ||||
-rwxr-xr-x | lastBackups.in.orig | 73 | ||||
-rw-r--r-- | man.commons.in | 13 | ||||
-rwxr-xr-x | remove-old-backups.in (renamed from removeOldBackups.in) | 4 |
11 files changed, 60 insertions, 95 deletions
@@ -1,10 +1,11 @@ backup backup@.service backup@.timer -backupStatistics -fastRepair -lastBackups -removeOldBackups +backup-progress +backup-statistics +fast-repair +last-backups +remove-old-backups man.commons *.common *.1 @@ -28,7 +28,13 @@ MANDIR = /usr/share/man VERSION = 1.3.4 -all: man.commons backup backup.1 backup@.service backup@.timer backupStatistics backupStatistics.1 lastBackups lastBackups.1 removeOldBackups removeOldBackups.1 +all: man.commons \ + backup backup.1 \ + backup@.service backup@.timer \ + backup-progress \ + backup-statistics backup-statistics.1 \ + last-backups last-backups.1 \ + remove-old-backups remove-old-backups.1 %: %.in sed " \ @@ -47,9 +53,9 @@ all: man.commons backup backup.1 backup@.service backup@.timer backupStatistics .PHONY: install dist clean install: all - install -D -m0755 -t $(DESTDIR)$(BINDIR) backup backupStatistics lastBackups removeOldBackups + install -D -m0755 -t $(DESTDIR)$(BINDIR) backup backup-progress backup-statistics last-backups remove-old-backups install -D -m0644 -t $(DESTDIR)$(LIBDIR)/systemd/system backup@.service backup@.timer - install -D -m0644 -t $(DESTDIR)$(MANDIR)/man1 backup.1 backupStatistics.1 lastBackups.1 removeOldBackups.1 + install -D -m0644 -t $(DESTDIR)$(MANDIR)/man1 backup.1 backup-statistics.1 last-backups.1 remove-old-backups.1 install -D -m0644 -t $(DESTDIR)$(ETCDIR) backup.conf clean: diff --git a/backup-progress.in b/backup-progress.in new file mode 100755 index 0000000..c5cb655 --- /dev/null +++ b/backup-progress.in @@ -0,0 +1,30 @@ +#!/bin/bash + +. #ETCDIR#/backup.conf + +export LC_ALL=C + +for backupID in "${!backups[@]}"; do + [ -s "/tmp/${backupID}.pid" ] || continue + kill -0 $(cat "/tmp/${backupID}.pid") || continue + dir="${backups["${backupID}"]%% *}" + last=$( + ls -1 "$dir" \ + | grep '[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}' \ + | sort \ + | tail -n1 + ) + last_size=$( + du -s "${dir}/${last}" \ + | awk '{print $1}' + ) + current_size=$( + du -s "${dir}/aktuell" \ + | awk '{print $1}' + ) + percentage=$( + printf '100*%s/%s\n' "${current_size}" "${last_size}" \ + | bc -l + ) + printf '%6.2f %% %s\n' "${percentage}" "${backupID}" +done diff --git a/backupStatistics.in b/backup-statistics.in index eb66e2c..a44f41d 100644 --- a/backupStatistics.in +++ b/backup-statistics.in @@ -1,6 +1,6 @@ #!/bin/bash -# backupStatistics version #VERSION# +# backup-statistics version #VERSION# set -e @@ -229,7 +229,7 @@ do_stage() usage() { >&2 echo \ -'Usage: backupStatistics [OPTION] +'Usage: backup-statistics [OPTION] Search and tidy duplicate and not-hardlinked files in the backups. With no options, tidy up all backups. THIS CAN BE VERY TIME CONSUMING. diff --git a/backup.conf b/backup.conf index 6043fb3..8d7fd4e 100644 --- a/backup.conf +++ b/backup.conf @@ -17,7 +17,7 @@ backups["proxiedBackup"]="/path/to/destination/ user@source:path proxy_user@ssh_ # which directories must be mounted before we can run successfully neededMounts=('/data') -# how long to wait for destination directories to appear in lastBackups [seconds] +# how long to wait for destination directories to appear in last-backups [seconds] maxWait=100 # how old may (seldom) backups be before we warn about outdated ones [seconds] @@ -35,5 +35,5 @@ seldomness=14 # subdirectories which should be appended to the parent directory in the report recognSubdirRegex="home\|boot\|root\|erich" -# directory for caching valuable information in backupStatistics +# directory for caching valuable information in backup-statistics cacheDir="/path/to/cache/directory" diff --git a/fastRepair.in b/fast-repair.in index fb89956..9d5224a 100644 --- a/fastRepair.in +++ b/fast-repair.in @@ -1,6 +1,6 @@ #!/bin/bash -# fastRepair version #VERSION# +# fast-repair version #VERSION# [ -r "/etc/backup.conf" ] && \ . "/etc/backup.conf" diff --git a/lastBackups.in b/last-backups.in index 9f0d3e8..a8ee5f2 100755 --- a/lastBackups.in +++ b/last-backups.in @@ -1,13 +1,13 @@ #!/bin/bash -# lastBackups version #VERSION# +# last-backups version #VERSION# [ -r "#ETCDIR#/backup.conf" ] && \ . "#ETCDIR#/backup.conf" usage () { >&2 echo \ -'Usage: lastBackups +'Usage: last-backups Show information about date of last backups and warn about outdated ones. Options: diff --git a/lastBackups.in.orig b/lastBackups.in.orig deleted file mode 100755 index ea6040a..0000000 --- a/lastBackups.in.orig +++ /dev/null @@ -1,73 +0,0 @@ -#!/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//" diff --git a/man.commons.in b/man.commons.in index 7227c2e..4ebb720 100644 --- a/man.commons.in +++ b/man.commons.in @@ -4,8 +4,9 @@ Erich Eckner <opensource at eckner dot net>. [SEE ALSO] backup(1) -lastBackups(1) -backupStatistics(1) +backup-statistics(1) +last-backups(1) +remove-old-backups(1) [CONFIG] The configfile \fB#ETCDIR#/backup.conf\fP is a bash script, which defines the following variables: .TP @@ -16,13 +17,13 @@ array of paths to exclude from backup array with command line arguments for predefined backups for \fBbackup\fP .TP .B "maxWait" -maximum time to wait for destination directories to appear in \fBlastBackups\fP and \fBbackupStatistics\fP [seconds] +maximum time to wait for destination directories to appear in \fBlast-backups\fP and \fBbackup-statistics\fP [seconds] .TP .B "outdatedLimit" -time before backups are considered outdated by \fBlastBackups\fP [seconds] +time before backups are considered outdated by \fBlast-backups\fP [seconds] .TP .B "recognSubdirRegex" -regular expression of subdirectories which should be appended to the parent directory in the report by \fBlastBackups\fP +regular expression of subdirectories which should be appended to the parent directory in the report by \fBlast-backups\fP .TP .B "cacheDir" -directory to store valuable information generated by \fBbackupStatistics\fP in +directory to store valuable information generated by \fBbackup-statistics\fP in diff --git a/removeOldBackups.in b/remove-old-backups.in index 145a6fd..c931409 100755 --- a/removeOldBackups.in +++ b/remove-old-backups.in @@ -1,13 +1,13 @@ #!/bin/bash -# removeOldBackups version #VERSION# +# remove-old-backups version #VERSION# [ -r "#ETCDIR#/backup.conf" ] && \ . "#ETCDIR#/backup.conf" usage () { >&2 echo \ -'Usage: removeOldBackups [-n] +'Usage: remove-old-backups [-n] Remove backups older than one year, keeping only one backup per month. Options: |