diff options
-rwxr-xr-x | backup.in | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -79,10 +79,10 @@ then exit 2 fi -neues_Datum=${Basis}/$(date "+%Y_%m_%d") -neues=${Basis}/aktuell +neues_Datum="${Basis}/$(date "+%Y_%m_%d")" +neues="${Basis}/aktuell" linkdests="" -for s in $(ls -1 ${Basis} | sort -r | grep -vm 20 aktuell ) +for s in $(ls -1 "${Basis}" | sort -r | grep -vxF -m 20 aktuell ) do linkdests="${linkdests} --link-dest ${Basis}/${s}" done @@ -93,11 +93,11 @@ then exit 3 fi -[ -w ${Basis} ] || exit 11 -[ -e ${neues_Datum} ] && exit 4 -[ -e ${pidFile} ] && exit 5 +[ -w "${Basis}" ] || exit 11 +[ -e "${neues_Datum}" ] && exit 4 +[ -e "${pidFile}" ] && exit 5 -echo $$ > ${pidFile} +echo $$ > "${pidFile}" if [ -n "${tunnelBefehl}" ] then @@ -111,18 +111,18 @@ do excludeArgs="${excludeArgs} --exclude ${toExclude}" done -if [ ! -e ${neues}/wip ] +if [ ! -e "${neues}/wip" ] then - mkdir -p ${neues}/wip + mkdir -p "${neues}/wip" fi -chmod 750 ${neues}{,/wip} -chown root:root ${neues}{,/wip} +chmod 750 "${neues}"{,/wip} +chown root:root "${neues}"{,/wip} if [ -z "${rsyncShell}" ] then rsync ${rsyncOptions} \ ${linkdests} \ ${excludeArgs} \ - ${Quelle} ${neues}/wip/ + ${Quelle} "${neues}/wip/" sleep 1 rsync ${Quelle} else @@ -130,21 +130,25 @@ else ${rsyncOptions} \ ${linkdests} \ ${excludeArgs} \ - ${Quelle} ${neues}/wip/ + ${Quelle} "${neues}/wip/" sleep 1 rsync "${rsyncShell}" ${Quelle} fi erg=$? -[ -n "${backgroundPid}" ] && kill ${backgroundPid} +[ -n "${backgroundPid}" ] && kill "${backgroundPid}" if [ ${erg} -eq 0 ] || [ ${erg} -eq 24 ] then - chmod o-rwx ${neues}/wip - mv ${neues}/wip ${neues_Datum} - rmdir ${neues} - rm ${pidFile} + chmod o-rwx "${neues}/wip" + neueres_Datum="${Basis}/$(date "+%Y_%m_%d")" + if [ ! -e "${neueres_Datum}" ]; then + neues_Datum="${neueres_Datum}" + fi + mv "${neues}/wip" "${neues_Datum}" + rmdir "${neues}" + rm "${pidFile}" else - rm ${pidFile} + rm "${pidFile}" exit 11 fi |