このbashスクリプトがありますが、「検索」ポイントでは機能しないようです。
#!/bin/bash
echo 'What date YYYY-MM-DD format?'
read date
echo "starting restore script..."
echo "Looking in /root/backups/dbback_$date/"
cd "/root/backups/dbback_$date/"
echo 'What search term for files?'
read search
echo 'What database am I restoring too?'
read database
count=`ls -l | grep "$search" | wc -l`
echo "$count files found containing $search"
find "/root/backups/dbback_$date/" -type f -name '$search*.sql.gz' -not -path '*livefiles*' | while read file; do
echo "$file is being restored"
gunzip < "$file" | mysql -u root -p* '$database';
echo "$file has been restored...moving on to next file."
done
発見と完了の間 - 何も起こらず、私が受け取った最後のエコーは次のとおりです。
テストを含む9つのファイルが見つかりました
私が何か間違っているなら、誰でも提案できますか?
答え1
find "/root/backups/dbback_$date/" -type f -name "${search}*.sql.gz" -not -path '*livefiles*' | while IFS= read -r file; do
echo "${file} is being restored"
gunzip < "${file}" | mysql -u root -p* $database;
echo "${file} has been restored...moving on to next file."
done
今有効