updatedb
prompt_list "Whick configuration_backup file do you want to use?" `find /restore/configuration/ -name configuration_backup* -type d`
BACKUP_OBJECT=${CHOICE}
echo "--------------------------------------"
cd ${CHOICE}
tar_gz=`find @etc@apache2@mods-available.tar.gz @etc@apache2@mods-enabled.tar.gz @etc@apache2@ports.conf.tar.gz @etc@apache2@sites-available.tar.gz \
@etc@apache2@sites-enabled.tar.gz`
echo "Founded Apache2 tar.gz files"
echo "--------------------------------------"
echo "${tar_gz}"
#tar -zvf ${tar_gz}
if [ -f "{$tar_gz}" ]
then
echo "found"
else
echo "not found"
fi
My problem now is the if and else. I want that the if statement finds the @etc@apache2 tar.gz files that i found with the "find" cmd so i can continue to extract the tar.gz files and other commands.
Somebody knows the good variabel of something else that can help?
If tar_gz holds more than one file name, the expression fails, as it has "too many arguments". Make sure to work on one file at a time, e.g. by using a for loop or similar.
Thank you for you message. I will make a for loop. But is necessary that all the 5 tar_gz are in the backup for the restore and if not that the restore script exits. Is this possible in a for loop you think?
I'm totally lost in it now.. I tried your piece of code.
tar_gz=( $(find @etc@apache2@mods-available.tar.gz @etc@apache2@mods-enabled.tar.gz @etc@apache2@ports.conf.tar.gz @etc@apache2@sites-available.tar.gz \
@etc@apache2@sites-enabled.tar.gz) )
if [ ${#tar_gz[@]} -ne 5 ]
then
echo "file set incomplete"
exit 1
fi
for FN in ${tar_gz[@]}
do
if [ -f $tar_gz ]
then
echo "found"
tar -zvf $tar_gz
fi
done
Want i want for this script:
Find all the 5 tar.gz files, if they're found than get a message and extract them if they're not found exit this script.