summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-10-11 13:32:46 +0200
committerErich Eckner <git@eckner.net>2016-10-11 14:24:11 +0200
commit903564349edb8e2ef457a5dbf09d3ed9c9c206f5 (patch)
treeef7a476c37e967d4df02ed21d5b38d4c9944d09e
parent42b083a197c3d29cce74c22606e16317f18f808b (diff)
downloadhardlinkedBackups-903564349edb8e2ef457a5dbf09d3ed9c9c206f5.tar.xz
alle manpages sollten jetzt funktionieren
-rw-r--r--Makefile22
-rwxr-xr-xbackup.in36
-rw-r--r--backupStatistics.in36
-rw-r--r--hardlinkedbackups.1.in82
-rwxr-xr-xlastBackups.in21
-rw-r--r--man.commons.in22
6 files changed, 102 insertions, 117 deletions
diff --git a/Makefile b/Makefile
index 805b51d..90b42c1 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@
# USA.
#
+SHELL = /bin/bash
DESTDIR =
ETCDIR = /etc
BINDIR = /usr/bin
@@ -26,15 +27,20 @@ MANDIR = /usr/share/man
VERSION = 1.1
-all: backup backup.1 lastBackups lastBackups.1 backupStatistics backupStatistics.1
+all: man.commons backup backup.1 lastBackups lastBackups.1 backupStatistics backupStatistics.1
%: %.in
- sed "s/#VERSION#/$(VERSION)/; s@#BINDIR#@$(BINDIR)@; s@#ETCDIR#@$(ETCDIR)@; s@#NUMSTAGES#@5@" $< > $@
-
-%.common: man.commons
- grep -v "^$(@:.common=)(" $< > $@
-
-%.1: % %.common
+ sed " \
+ s/#VERSION#/$(VERSION)/; \
+ s@#BINDIR#@$(BINDIR)@; \
+ s@#ETCDIR#@$(ETCDIR)@; \
+ s@#NUMSTAGES#@5@; \
+ s@#HELPTEXT#\(\s\+\)#@ --help \1display this help and exit\n --version\1display version and exit@; \
+ " $< > $@ && \
+ ( [[ "$@" = *.* ]] || chmod +x "$@" )
+
+%.1: % man.commons
+ grep -v "^$<(" man.commons | sed '/^\[SEE ALSO]$$/{n;:a;N;/\[/b;s/\n/, /;ta;}' > "$<.common" && \
help2man -o "$@" -N --include $<.common --no-discard-stderr "./$<"
.PHONY: install dist clean
@@ -45,7 +51,7 @@ install: all
install -D -m0644 -t $(DESTDIR)$(ETCDIR) backup.conf
clean:
- cat .gitignore | xargs rm -f
+ git clean -x -d -f
dist: clean
git status --porcelain 2> /dev/null | grep -q "\S" && (git add .; git commit -m"neue Version: $(VERSION)") || true
diff --git a/backup.in b/backup.in
index 0a61933..33a59f3 100755
--- a/backup.in
+++ b/backup.in
@@ -1,18 +1,38 @@
#!/bin/bash
-. #ETCDIR#/backup.conf
+[ -r "#ETCDIR#/backup.conf" ] && \
+ . "#ETCDIR#/backup.conf"
usage()
{
- >&2 echo 'This is backup version #VERSION#'
- >&2 echo ''
- >&2 echo 'usage:'
- >&2 echo ' backup /tmp/pidFile /path/to/destination/ user@source:path'
- >&2 echo ' backup /tmp/pidFile /path/to/destination/ user@source:path proxy_user@ssh_host'
- >&2 echo 'or as a symlink (e.g. in /etc/cron/daily) named after a key of $backups in #ETCDIR#/backup.conf without arguments'
- exit 1
+ >&2 echo \
+'Usage: backup /tmp/pidFile /path/to/destination/ user@source:path [proxy_user@ssh_host]
+Backup files from remote with rsync, possibly via SSH-tunnel.
+
+With no arguments, information is expected to be in array $backups in #ETCDIR#/backup.conf with name of executable (e.g. a symlink) as key.
+
+Options:
+ /tmp/pidFile location of file to store PID in
+ /path/to/destination location to store backups in
+ user@source:path remote data to back up
+ proxy_user@ssh_host ssh login to proxy node (optional)
+#HELPTEXT# #'
+ [ -z "$1" ] && exit 1
+ exit $1
}
+if [ $# -eq 1 ]
+then
+ if [ "$1" == "--help" ]
+ then
+ usage 0
+ elif [ "$1" == "--version" ]
+ then
+ echo '#VERSION#'
+ exit
+ fi
+fi
+
if [ $# -eq 0 ]
then
backupID="$(basename $0)"
diff --git a/backupStatistics.in b/backupStatistics.in
index d5511bf..b0a0062 100644
--- a/backupStatistics.in
+++ b/backupStatistics.in
@@ -2,7 +2,8 @@
# backupStatistics version #VERSION#
-. #ETCDIR#/backup.conf
+[ -r "#ETCDIR#/backup.conf" ] && \
+ . "#ETCDIR#/backup.conf"
do_stage()
{
@@ -108,19 +109,20 @@ do_stage()
usage()
{
- >&2 echo 'Usage: backupStatistics [OPTION]'
- >&2 echo 'Search and tidy duplicate and not-hardlinked files in the backups.'
- >&2 echo ''
- >&2 echo 'With no options, tidy up all backups. THIS CAN BE VERY TIME CONSUMING.'
- >&2 echo ''
- >&2 echo 'Mandatory arguments to long options are mandatory for short options too.'
- >&2 echo ' -d | --dummy only generate lists, do not modify backupfiles'
- >&2 echo ' -h | --help display this help and exit'
- >&2 echo ' -m | --max=maxNum stop execution after step maxNum'
- >&2 echo ' -s | --skip=skipNum skip first skipNum steps'
- >&2 echo ' -V | --version display version and exit'
- >&2 echo ''
- >&2 echo 'the executed steps are:'
+ >&2 echo \
+'Usage: backupStatistics [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.
+
+Mandatory arguments to long options are mandatory for short options too.
+ -d, --dummy only generate lists, do not modify backupfiles
+ -m, --max=maxNum stop execution after step maxNum
+ -s, --skip=skipNum skip first skipNum steps
+#HELPTEXT# #
+
+the executed steps are:'
+
for ((stage=1; stage<=#NUMSTAGES#; stage++))
do
>&2 echo ''
@@ -132,7 +134,7 @@ usage()
}
eval set -- "$(
- getopt -o dhm:s:V \
+ getopt -o dm:s: \
--long dummy \
--long help \
--long max: \
@@ -151,7 +153,7 @@ while true; do
-d|--dummy)
dummy=true
;;
- -h|--help)
+ --help)
usage 0
;;
-m|--max)
@@ -162,7 +164,7 @@ while true; do
shift
skipNum=$1
;;
- -V|--version)
+ --version)
>&2 echo '#VERSION#'
exit 0
;;
diff --git a/hardlinkedbackups.1.in b/hardlinkedbackups.1.in
deleted file mode 100644
index 7902568..0000000
--- a/hardlinkedbackups.1.in
+++ /dev/null
@@ -1,82 +0,0 @@
-.TH hardlinkedbackups 1 "" "hardlinkedbackups #VERSION#" ""
-.SH NAME
-hardlinkedbackups \- hardlinked incremental backups via rsync (and possibly through a SOCKS\-tunnel via ssh)
-.SH SYNOPSIS
-.TP
-\fBbackup /tmp/pidFile /path/to/destination/ user@source:path [proxy_user@ssh_host]\fP
-.TP
-\fBlastBackups\fP
-.TP
-\fBbackupStatistics [options]\fP
-.SH DESCRIPTION
-\fBbackup\fP generates incremental backups (by hardlinking old unchanged files) via rsync and possibly a SOCKS\-tunnel.
-\fBlastBackups\fP shows date of backups and warns about outdated ones.
-\fBbackupStatistics\fP exhaustively searches backups for duplicate but not hard-linked files.
-.SH USAGE
-.TP
-.B "backup /tmp/pidFile /path/to/destination/ user@source:path"
-Creates incremental backup in \fB/path/to/destination/\fP from \fBuser@source:path\fP, saving its PID in \fB/tmp/pidFile\fP.
-.TP
-.B "backup /tmp/pidFile /path/to/destination/ user@source:path proxy_user@ssh_host"
-Same as above, but tunneling via SSH through \fBproxy_user@ssh_host\fP.
-.TP
-.B "symLinkName -> #BINDIR#/backup"
-Same as one of the above.
-Command line parameters are filled from variable \fB$backups["symLinkName"]\fP in \fB#ETCDIR#/backup.conf\fP.
-This is designed to be called from a cron daemon for daily backups.
-.TP
-.B "lastBackups"
-reports about actuality of backups defined in \fB#ETCDIR#/backup.conf\fP
-.TP
-.B "backupStatistics"
-Exhaustively search backups defined in \fB#ETCDIR#/backup.conf\fP for duplicate files which are not hard linked.
-For detail see section \fBBACKUPSTATISTICS\fP.
-.SH BACKUPSTATISTICS
-execution happens in several stages:
-.TP
-1.
-.TP
-blabla
-.TP
-.B "-d | --dummy"
-do not modify backed up files
-.TP
-.B "-m | --max \fImaxStage\fP"
-stop execution after completing stage \fImaxStage\fP
-.TP
-.B "-s | --skip \fIskipStages\fP"
-start execution right after stage \fIskipStages\fP
-.SH CONFIGURATION
-The configfile \fB#ETCDIR#/backup.conf\fP is a bash script, which defines the following variables:
-.TP
-.B "excludes"
-array of paths to exclude from backup
-.TP
-.B "backups"
-array with command line arguments for predefined backups
-.TP
-.B "maxWait"
-maximum time to wait for destination directories to appear in lastBackups [seconds]
-.TP
-.B "outdatedLimit"
-time before backups are considered outdated [seconds]
-.TP
-.B "recognSubdirRegex"
-regular expression of subdirectories which should be appended to the parent directory in the report
-.TP
-.B "cacheDir"
-directory for caching valuable information in \fBbackupStatistics\fP
-.SH FILES
-.TP
-.B "#BINDIR#/backup"
-program for creation of backups
-.TP
-.B "#BINDIR#/lastBackups"
-program for check of backups
-.TP
-.B "#ETCDIR#/backup.conf"
-configuration of backups
-.SH AUTHOR
-.nf
-Erich Eckner <opensource at eckner dot net>
-.fi
diff --git a/lastBackups.in b/lastBackups.in
index 6366058..e0cefd2 100755
--- a/lastBackups.in
+++ b/lastBackups.in
@@ -2,7 +2,26 @@
# lastBackups version #VERSION#
-. #ETCDIR#/backup.conf
+[ -r "#ETCDIR#/backup.conf" ] && \
+ . "#ETCDIR#/backup.conf"
+
+if [ $# -eq 1 ]
+then
+ if [ "$1" == "--help" ]
+ then
+ >&2 echo \
+'Usage: lastBackups
+Show information about date of last backups and warn about outdated ones.
+
+Options:
+#HELPTEXT# #'
+ exit 0
+ elif [ "$1" == "--version" ]
+ then
+ >&2 echo '#VERSION#'
+ exit 0
+ fi
+fi
unset namen
unset veraltet
diff --git a/man.commons.in b/man.commons.in
index 45918c7..7227c2e 100644
--- a/man.commons.in
+++ b/man.commons.in
@@ -4,5 +4,25 @@
Erich Eckner <opensource at eckner dot net>.
[SEE ALSO]
backup(1)
-lastBackup(1)
+lastBackups(1)
backupStatistics(1)
+[CONFIG]
+The configfile \fB#ETCDIR#/backup.conf\fP is a bash script, which defines the following variables:
+.TP
+.B "excludes"
+array of paths to exclude from backup
+.TP
+.B "backups"
+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]
+.TP
+.B "outdatedLimit"
+time before backups are considered outdated by \fBlastBackups\fP [seconds]
+.TP
+.B "recognSubdirRegex"
+regular expression of subdirectories which should be appended to the parent directory in the report by \fBlastBackups\fP
+.TP
+.B "cacheDir"
+directory to store valuable information generated by \fBbackupStatistics\fP in