summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-02-10 22:36:04 +0100
committerErich Eckner <git@eckner.net>2019-02-10 22:36:04 +0100
commit314ad8d94c5ff33fd2eadb1027748550be0e7e4f (patch)
treeb94d525ac5758380cbc8cbcc8bce8e5b68823697
parent080efe8cbf8e5bc69a17f8af8f5feffd01dd67fe (diff)
downloadhardlinkedBackups-314ad8d94c5ff33fd2eadb1027748550be0e7e4f.tar.xz
camelCase -> no-camel-case, backup-progress new
-rw-r--r--.gitignore9
-rw-r--r--Makefile12
-rwxr-xr-xbackup-progress.in30
-rw-r--r--backup-statistics.in (renamed from backupStatistics.in)4
-rw-r--r--backup.conf4
-rwxr-xr-xcheck-diff (renamed from checkDiff)0
-rw-r--r--fast-repair.in (renamed from fastRepair.in)2
-rwxr-xr-xlast-backups.in (renamed from lastBackups.in)4
-rwxr-xr-xlastBackups.in.orig73
-rw-r--r--man.commons.in13
-rwxr-xr-xremove-old-backups.in (renamed from removeOldBackups.in)4
11 files changed, 60 insertions, 95 deletions
diff --git a/.gitignore b/.gitignore
index 08432d6..b917e42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile b/Makefile
index 639a375..49ee698 100644
--- a/Makefile
+++ b/Makefile
@@ -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/checkDiff b/check-diff
index 8643e04..8643e04 100755
--- a/checkDiff
+++ b/check-diff
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: