I make daily backups of the mysql database storing the contents of my online website, and I would like to automate those half-dozen commands into a single command.
I tried a naïve solution, by simply putting the list of commands into a Bash script. This fails, as the script stops once it's entered the remote host.
Any help appreciated.
My failed (bash script) attempt :
#! /bin/bash echo "Connecting to the remote host ..."; ssh -p myport email@example.com ; echo "Making the backup on the remote host ..."; mysqldump --databases --user=mysqluser --password=mypassword mydatabase > backup_copy.sql ; echo "Compressing the sql backup ..."; gzip backup_copy.sql; echo "Leaving the remote host ..."; exit; echo "Copying the backup from the remote host ..."; scp -P myport firstname.lastname@example.org:backup_copy.sql.gz /my/location/to/store/backups ; echo "Task finished";