I recently had to backup a WordPress site that I only had shell (SSH) access to – no fancy hosting admin panel. This can be used for any PHP/MySQL site.
Backup the database
- Log into hosting server via SSH by downloading an SSH client like Putty. You’ll need the server name, and user name and a password for SSH access to the server.
- Once you are in display the MySQL databases (remember the semi-colon)
#mysql mysql>show databases; mysql>exit;
- Identify the database your website is using (in wordpress you can find this in wp-config.php) and dump the database (in this case WordPressDB2) to something like wordpress.sql (http://www.pantz.org/software/mysql/mysqlcommands.html):
#mysqldump -uroot -pnDnxQArK WordPressDB2 > wordpress.sql
- I then rename my backups with a time and date stamp – in the style wordpress_20120501_1040.sql – and FTP to local PC using a FTP client like FileZilla.
Backup the source code
- Compress the source code by running this command from the root folder (the one with the wordpress folder) to create wordpress.zip.
#zip -r wordpress.zip wordpress
- I then rename the zip with time and date stamp – in style wordpress_20120501_1047.zip – and FTP to the local PC.