backup and zip all mysql databases shell script
This isn't rocket science but probably something good to share for anyone making the move to Linux for web hosting. Below is a quick script that I run daily to back up all MySQL DB's which then have placed somewhere safe.
Open Nano/Vi/Gedit and create a file called mysql_backup.sh then add the following lines:
#!/bin/bash cd /tmp/ echo "creating mysqldump in /tmp/all-database.sql" mysqldump -u YOUR_USERNAME -pYOUR_PASSWORD --all-databases > all-database.sql echo "Next we tar/zip the file" tar cvf db_dump.tar all-database.sql echo "All done!"
At the moment this is just a text file which cannot be executed via the terminal, so to fix this run the following:
chmod 755 mysql_backup.sh
Then you can run this as any normal shell script
There is a lot more you can do with this like moving the file to another location, delete the dump behind you etc, but this should give you a good starting ground.