0
我有下面的腳本,我想運行一個cPanel備份後創建(每個網站1.tar.gz文件)來檢查壓縮文件。它不是要取代手動測試恢復,而只是一個額外的檢查。問題不在於重新調整檢查失敗的文件列表,而是返回所有文件的列表。一個bash腳本來檢查tar.gz文件
#!/bin/bash
date=`date +%Y-%m-%d`
path="/backups/$date/*.gz"
found_errors=0
errors='The following backup files failed the automatic test: \n'
for f in $path
do
gunzip -c $f | tar t > /dev/null
#if the exit status was not 0
if [ $?=0 ]; then
found_errors=1
errors="$errors\n$f"
#echo $f ": Exit status code is " $?
fi
done
#if an error was found
if [ $found_erros!=0 ]; then
#email the list of files that could not be extracted/tested
echo -e $errors | mail -s "Backup Error Check" "[email protected]"
fi
在此先感謝。