more safety. check if files exists..

pull/1/head
xor 2015-10-04 23:11:17 +02:00
parent 4920769d5b
commit ed2415cc34
1 changed files with 23 additions and 25 deletions

View File

@ -132,30 +132,25 @@ then
then then
die 0 die 0
else else
for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep '<' | cut -d'*' -f2 | sed 's/\ /\\ /g' ); for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep -v '^#' | grep '<' | cut -d'*' -f2 | sed 's/\ /\\ /g' );
do do
#lösche_aus_tar #lösche_aus_tar
echo tar --delete -z -v -f $BACKUP_FILE $file tar --delete -v -f $BACKUP_FILE $file
done done
for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep '>' | cut -d'*' -f2 | sed 's/\ /\\ /g' ); for file in $(diff ${DIGEST_FILE} ${DIGEST_FILE_TMP} | grep -v '^#' | grep '>' | cut -d'*' -f2 | sed 's/\ /\\ /g' );
do do
echo tar -r -z -v -f $BACKUP_FILE $file tar -r -v -f $BACKUP_FILE $file
done done
#mv -v ${DIGEST_FILE_TMP} ${DIGEST_FILE} || die 7
fi fi
else else
write_hashes $DIGEST_FILE write_hashes $DIGEST_FILE
fi tar -cpPf ${BACKUP_FILE} ${MBR_TMP} /boot ${DIGEST_FILE} || die 7 "Error writing ${BACKUP_FILE}"
#Backup of good files
tar -czpPf ${BACKUP_FILE} /boot ${DIGEST_FILE}
if [ $? == 0 ]
then
echo "Backup written to ${BACKUP_FILE}" echo "Backup written to ${BACKUP_FILE}"
else
die 7 "Error writing ${BACKUP_FILE}"
fi fi
elif [ "${1}" == "check" ] elif [ "${1}" == "check" ]
then
[ -f ${DIGEST_FILE} ]
then then
HASHER=$(head -n1 ${DIGEST_FILE} | awk '{print $5}') HASHER=$(head -n1 ${DIGEST_FILE} | awk '{print $5}')
@ -171,6 +166,9 @@ then
COUNTER=$((COUNTER + 2)) COUNTER=$((COUNTER + 2))
die $COUNTER die $COUNTER
fi fi
else
#error no digest file
fi
elif [ "${1}" == "recover" ] elif [ "${1}" == "recover" ]
then then
echo "Restoring files from backup... (type yes or no for each file)" echo "Restoring files from backup... (type yes or no for each file)"