Overview
This article will walk you through how to create timestamped database back-up of your website on the Grid.
READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.
Steps
- Decide which database you want to back-up. I want to back-up a WordPress database called "dbXXXXX_dbname", for the website "example.com".
- Log into SSH and enter your domain's document root.
cd domains/example.com
- Use VI or VIM to create a new file named 'backup.sh':
vim backup.sh
- Add the following information into the file, replacing the placeholders with your Grid & database username / password / name, and then save:
#!/bin/sh cd ~/domains/example.com mysqldump -h internal-db.sXXXXXX.gridserver.com --add-drop-table -uXXXXX -pXXXXX dbXXXXX_dbname > database-backup-`date '+%Y.%m.%d'`.sql
- Run a command which will make the file executable by you, the owner:
chmod 744 backup.sh
- Just to make sure it works, test it out:
./backup.sh
- If you entered the mysqldump command correctly, you should not see any error messages on the screen. To show that the command ran, when you perform a list directory command (ls), you should see a file called "database-backup11.15.10.zip", or whatever is the corresponding date. So now that we have a working script, it's time to make a regularly occurring job out of it.
/home/XXXXXX/domains/example.com/backup.sh