I have made a simple backup script
Code:
function backups_remove_file
{
echo ""
echo "2. Make Backups Of Files(s)"
echo ""
echo "Which File You Wanna To Make Backups?"
read back
echo "What's The File's Name Should Be After Backups? And Where?"
read after
read -p "Continue (y/n)?" CONT1
if [ "$CONT1" == "y" ]; then
tar -cvpzf "$after.tar.gz" "$back"
echo "Backups File Successful !" ;
else
echo "Backups File Unsuccessful !" ;
fi
}
But there is one small problem I could not fix. When it shows
Which File You Want To Make Backups?
if you write for example "test" after that, and for the next question
What's The File's Name Should Be After Backups? And Where?
if you write for example "test1", then there will be a safety issue if they want to continue or not if type y
it will output:
taking: test: can not state: No such file or directory
tar: Exiting with failure status due to previous errors
Backups File Successful!
The output in that case should be Backups File Unsuccessful!
. What should I do to get the expected output in this case?
bktar='tar -cvpzf "$after.tar.gz" "$back"'
or something like that instead of pointlessly creating a function.