diff options
author | Erich Eckner <git@eckner.net> | 2017-11-10 13:37:35 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-11-10 13:38:30 +0100 |
commit | 970409c2b14473b26a4938cfb36939f4321edfb7 (patch) | |
tree | 7832128df79d324f2481c7e606ce654eec94e195 | |
parent | 7c98067307218e3213cf8007afce0461d02b45f2 (diff) | |
download | hardlinkedBackups-970409c2b14473b26a4938cfb36939f4321edfb7.tar.xz |
backup: mehr ", zum wirklich aktuellen Datum umbenennen
-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 |