patty1 wrote:Thanks, I had Sonic install WP, so I don't have access to the SQL database.
Is that where theme customizations are stored?
While the auto-installed WordPress database is hidden from phpMyAdmin, you can still access it from shell using the credentials and information from the wp-config.php file (DB_HOST, DB_NAME, DB_USER, DB_PASSWORD). You can connect directly using the mysql client on shell.sonic.net, or use those values in backup scripts that run from shell.sonic.net to run mysqldump.
If you edit theme PHP files directly in the Theme Editor, this generally modifies the theme files in wp-content/themes. Customizations made through theme administration panels would be stored in the database.
Posts, pages, users, menus, and meta-data about media uploads are all stored in the database.
Thus to have a full WordPress site backup, it's imperative to backup both the database *and* files on the server and keep them together as a single backup.
Here is a shell script I use to back up a WP site on Sonic's hosting. I make no guarantees of it's reliability and modifications or troubleshooting is beyond the scope of our support but it's a starting point for power users.
You can run it from shell.sonic.net by hand or regularly as a cron job. "domain.com" must be changed to the domain you want to back up and the DB values up top changed to those found in your wp-config.php file.
It will create the directory "wordpress_backups" in your home directory and keep them there. It works by creating mysqldump of the WP database, and then backs up all the WP files and folders into a .tar.gz file. Backups older than 14 days will be deleted automatically.
Code: Select all
#!/bin/bash
# MySQL database configurations
DB_USER="username_oc_2"
DB_PASS="db password here"
DB_NAME="username_oc_2"
# Where backups are kept
BACKUP_DIR="$HOME/wordpress_backups"
if [ ! -d "$BACKUP_DIR" ] ; then
# Create backup directory if it does not exist
mkdir "$BACKUP_DIR"
fi
# get date & time for backup file name
date=`date +%Y%m%d-%H%I%S`
# export wordpress mysql database to file
mysqldump -h b.custsql.sonic.net -u $DB_USER -p"$DB_PASS" $DB_NAME > "$BACKUP_DIR/wordpress-$date.sql"
if [ $? != 0 ] ; then
echo "Wordpress MySQL backup failed!"
exit 2
fi
# backup wordpress files, themes, plugins, media
tar cfz "$BACKUP_DIR/wordpress-$date.tar.gz" $HOME/public_html/otheremail.org
if [ $? != 0 ] ; then
echo "Failed to archive WordPress files!"
exit 2
fi
# delete backups older than 14 days; "-name" ensureswe only our backups are deleted
find "$BACKUP_DIR" -maxdepth 1 -name "wordpress-*" -type f -mtime +14 -delete -print
exit 0
To run it, you would save this to a file in your home directory on shell.sonic.net (e.g. backup_wordpress.sh), give it execute permissions (chmod +x backup_wordpress.sh) and then run it as "./backup_wordpress.sh"
It's just a robust as a backup plugin, if not more, but if getting that set up sounds confusing, a plugin is probably the best way to go. There should be some that can create backups without needing the "zip" extension built in. Restoring from that backup simply involves extracting and overwriting all the files, and importing the SQL dump which will erase all the old info from the database and replace it with the backup.