Re: Takes courage
To run rm -rf with parameters in a script.
First, you test for the parameters to have valid values
if [[ -z "$1" || -z "$2" ]]
then
echo "Variables not set"
else
echo "rm -rfi $1/$2"
fi
as well as turning whatever command you're trying into an echo statement. Similarly, you test for reasonable values retrieved from the database.
Then, you run this on a sacrificial environment.
Then, you run this on a sacrificial environment, capturing the output. You inspect this to contain the commands you expect.
Then, you run the captured output as a script. After you've verified that it does what you intended for the first couple of lines, you ctrl-c the script, remove the '-i' and re-run it.
Then, you verify the restorability of your backups.
Then, you verify the restorability of your backups again.
Only then you run the script on your live environment.
.