Use &&
between commands: it will execute the next command only if the previous command execution is a success. The ||
does the inverse => echo "error"
will be displayed if one of the both cp
fails.
#!/bin/sh
cp ~/SURV/plugins/iConomy/accounts.mini ~/backups/ &&
cp ~/SURV/plugins/CoreProtect/database.db ~/backups/ &&
echo "Backups creados con éxito!" ||
echo "error"
You can also add -v
option to the cp
command for more visibility.
In order to make your script executable you have to do:
chmod +x backup.sh