fix sync after stop
This commit is contained in:
parent
5e967fb569
commit
e44ba4f643
19
masync
19
masync
@ -87,12 +87,25 @@ feeddeletes() {
|
|||||||
echo "grep $1 ${SYNCFILE}"
|
echo "grep $1 ${SYNCFILE}"
|
||||||
grep $1 ${SYNCFILE} | while read hash pid when status localpath remotepath; do
|
grep $1 ${SYNCFILE} | while read hash pid when status localpath remotepath; do
|
||||||
remoterelativepath=$(echo "$remotepath" | cut -d : -f 2)
|
remoterelativepath=$(echo "$remotepath" | cut -d : -f 2)
|
||||||
|
remotehost=$(echo "$remotepath" | cut -d : -f 1 | cut -d @ -f 2)
|
||||||
|
remotefiles=$(mktemp)
|
||||||
|
## request list of remote files to remotehost
|
||||||
|
ssh ${remotehost} find "'${remoterelativepath}'" > ${remotefiles}
|
||||||
|
## read my snapshot
|
||||||
while read path; do
|
while read path; do
|
||||||
if [ ! -e "${path}" ]; then
|
if [[ -e "${path}" ]]; then
|
||||||
echo "${path} not exists"
|
tocheckremotepath=$(echo "${path}" | sed -e "s~${localpath}~${remoterelativepath}~g")
|
||||||
echo ${path} | sed -e "s~${localpath}~${remoterelativepath}~g" | tee -a ${queuedeletes}
|
if ! grep -Fxq "${tocheckremotepath}" ${remotefiles}; then
|
||||||
|
echo "${tocheckremotepath} not exists in remote remove ${path} in local";
|
||||||
|
rm -rf "${path}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "${path} Noexits";
|
||||||
|
## if controlled file doesn't exist in local delete it on remote
|
||||||
|
echo "${path}" | sed -e "s~${localpath}~${remoterelativepath}~g" | tee -a ${queuedeletes}
|
||||||
fi
|
fi
|
||||||
done < ${snapfile}
|
done < ${snapfile}
|
||||||
|
rm -rf ${remotefiles}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user