summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-01-02 21:06:07 +0100
committerErich Eckner <git@eckner.net>2019-01-02 21:06:07 +0100
commita812c1b07c7de16f3bb4d08ed697b36b701f05b9 (patch)
tree2f86f1326e09332bbcac3ffdc9f6dac8a544ee11
parent344b58df35db8e7cd0af1181220c3da9b5f3aa84 (diff)
downloadhardlinkedBackups-a812c1b07c7de16f3bb4d08ed697b36b701f05b9.tar.xz
backup.in: style
-rwxr-xr-xbackup.in48
1 files changed, 16 insertions, 32 deletions
diff --git a/backup.in b/backup.in
index f71ede3..6723699 100755
--- a/backup.in
+++ b/backup.in
@@ -26,21 +26,17 @@ Options:
exit $1
}
-if [ $# -eq 1 ]
-then
- if [ "$1" == "--help" ]
- then
+if [ $# -eq 1 ]; then
+ if [ "$1" == "--help" ]; then
usage 0
- elif [ "$1" == "--version" ]
- then
+ elif [ "$1" == "--version" ]; then
echo '#VERSION#'
exit
fi
fi
seldom=false
-if [ $# -eq 0 ]
-then
+if [ $# -eq 0 ]; then
backupID="$(basename $0)"
[ -z "${backups[${backupID}]}" ] && usage
set /tmp/${backupID}.pid ${backups[${backupID}]}
@@ -54,11 +50,9 @@ Basis="$2"
pidFile="$1"
QuellIP=$(echo "$3" | sed "s|^[a-zA-Z]*://||; s|^[a-zA-Z]*@||; s|:\?/.*$||")
-if [ "$#" -eq 3 ]
-then
+if [ "$#" -eq 3 ]; then
Quelle="$3"
-elif [ "$#" -eq 4 ]
-then
+elif [ "$#" -eq 4 ]; then
sshHopp="$4"
lokPort=$[$RANDOM/2+8000]
rsyncShell="-e ssh -6 -p${lokPort} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
@@ -69,17 +63,14 @@ else
usage
fi
-if [ -n "${QuellIP}" ]
-then
+if [ -n "${QuellIP}" ]; then
ping -c1 ${QuellIP} > /dev/null || exit 11
fi
-if [ -n "${HoppIP}" ]
-then
+if [ -n "${HoppIP}" ]; then
ping -c1 ${HoppIP} > /dev/null || exit 11
fi
-if [ ! -d ${Basis} ]
-then
+if [ ! -d ${Basis} ]; then
[ $(mount | grep -c "\S\+\s\+\S\+\s\+/var/ftp\s") -eq 0 ] && exit 11
exit 2
fi
@@ -87,13 +78,11 @@ fi
neues_Datum="${Basis}/$(date "+%Y_%m_%d")"
neues="${Basis}/aktuell"
linkdests=""
-for s in $(ls -1 "${Basis}" | sort -r | grep -vxF -m 20 aktuell )
-do
+for s in $(ls -1 "${Basis}" | sort -r | grep -vxF -m 20 aktuell ); do
linkdests="${linkdests} --link-dest ${Basis}/${s}"
done
-if [ ! "$(whoami)" == "root" ]
-then
+if [ ! "$(whoami)" == "root" ]; then
echo "I need to be root."
exit 3
fi
@@ -111,26 +100,22 @@ fi
echo $$ > "${pidFile}"
-if [ -n "${tunnelBefehl}" ]
-then
+if [ -n "${tunnelBefehl}" ]; then
${tunnelBefehl} &
backgroundPid=$!
sleep 4
fi
-for toExclude in "${excludes[@]}"
-do
+for toExclude in "${excludes[@]}"; do
excludeArgs="${excludeArgs} --exclude ${toExclude}"
done
-if [ ! -e "${neues}/wip" ]
-then
+if [ ! -e "${neues}/wip" ]; then
mkdir -p "${neues}/wip"
fi
chmod 750 "${neues}"{,/wip}
chown root:root "${neues}"{,/wip}
-if [ -z "${rsyncShell}" ]
-then
+if [ -z "${rsyncShell}" ]; then
rsync ${rsyncOptions} \
${linkdests} \
${excludeArgs} \
@@ -150,8 +135,7 @@ erg=$?
[ -n "${backgroundPid}" ] && kill "${backgroundPid}"
-if [ ${erg} -eq 0 ] || [ ${erg} -eq 24 ]
-then
+if [ ${erg} -eq 0 ] || [ ${erg} -eq 24 ]; then
chmod o-rwx "${neues}/wip"
neueres_Datum="${Basis}/$(date "+%Y_%m_%d")"
if [ ! -e "${neueres_Datum}" ]; then