There are two different ways to upgrade and maintain your WordPress installation:
- Use the built-in upgrade feature in Wordpress. You can go you your Admin panel and update any plugin, theme or the application itself from the Wordpress dashboard: Dashboard -> Updates
- Migrate your application to a new BitNami AMI with an updated version of the application and/or underlying components. We recommend that you do this from time to time to make sure that you not only have the best and latest version of Wordpress, but also have the latest (and most secure) versions of Apache, MySQL and other software that Wordpress runs on. We regularly refresh the images available in the BitNami library to make sure that you always have access to the most up-to-date software.
This guide describes how to migrate your BitNami WordPress instance to a new AMI (Amazon Machine Image) version. In this guide, we will refer to the servers that you have running Wordpress as "instances", which is the terminology that Amazon uses.
How can I create a backup of my instance?
We strongly recommend that you create a backup of your current instance if you are going to do major changes or upgrades. It is not absolutely necessary if you are migrating the data to a new instance because the process does not modify your current instance, but in general it is a best-practice to make a backup before starting on any process where you will be accessing or making changes to your server, particularly if you are new to the process.
There are different ways to create a backup. For this tutorial, we will use the snapshot feature of the Amazon Cloud.
To create a snapshot with a consistent file system, you should stop the server(s) before taking the snapshot. If you have never logged into your machine, see this guide for instructions on connecting to your instance. Once you are logged in, run this command to stop the server(s):
$ sudo /opt/bitnami/ctlscript.sh stop
You can now create a new EBS image (snapshot) based on this instance.
If you run into issues during this process, you can simply launch a new instance from this snapshot and restart the process.
How do I migrate the data to a new BitNami WordPress instance?
Backing up the files
This section describes how to sync the WordPress data from your previous instance to a new instance running a later release of the BitNami WordPress AMI. First, log in to your current instance (or your backed up version) of WordPress.
- Create a database backup. Run the following command line command to create a database backup:
$ mysqldump -u root -p bitnami_wordpress > /home/bitnami/wordpress_backup.sql
The default database root password is "bitnami". If you are using BitNami Cloud Hosting, the password is the one that you specified during the server launch process. If you did not specify a password at that time, one was automatically generated for you. In that case, you can retrieve it by going to Servers -> Manage and then click on "show" in the Application Password row to display your password.
You can also create a backup through the phpMyAdmin interface.
- Create a backup of the files. Uploaded images, themes and plugins are saved in the wp-content folder. If you want to preserve this data, you can create a backup of this folder by doing the following:
$ cd /opt/bitnami/apps/wordpress/htdocs $ sudo tar -czvf /home/bitnami/wp-content_backup.tar.gz wp-content
- Create a backup of the configuration files. If you have configured WordPress to run in the root URL, you may have modified the WordPress configuration file /opt/bitnami/apps/wordpress/conf/wordpress.conf file. If this is the case, create a copy of this file:
$ cp /opt/bitnami/apps/wordpress/conf/wordpress.conf /home/bitnami/wordpress_backup.conf
You now have all of the required data to migrate your blog to a new instance. If you have customized the php.ini, my.cnf, httpd.conf or any other configuration files, you may also want to update the configuration files in the new instance.
Copying files to the new instance
To copy your files from the old instance to the new one, complete the following steps:
- Download the backup files to your machine. To download the backed up files to your local machine (so you can upload them to a new one), you can either use the "SCP" command to download them or use your preferred sFTP client. For this tutorial, we will use the SCP command line tool:
$ scp -i /path/to/your/private_key.pem bitnami@old_server:*backup* .
Tip: You can also send the files from the old one to the new one directly. Assuming both servers were started with the same AWS cloud credentials, you can use the same SSH key to connect to both servers. On your local host, add your ssh key to the SSH agent:
$ ssh-add /path/to/your/private_key.pem
- Start the new instance. Now, start the new version of the BitNami WordPress AMI. You can view and access the latest version from the BitNami WordPress page. You can also start a BitNami AMI with a different operating system: Ubuntu, RedHat, etc, if you would like to switch operating systems at this time.
- Upload the files to the new instance. To upload the database backup and files that you downloaded in the first step in this section to the new instance, use the sFTP client:
$ scp -i /path/to/your/private_key.pem wordpress_backup.sql wp-content_backup.tar.gz wordpress_backup.conf bitnami@new_server:
Restoring files in the new instance
You can now restore the database and the WordPress files in the new installation by doing the following:
- Restore the database. Populate the new application with your data from the previous installation:
$ mysql -u root -p bitnami_wordpress < /home/bitnami/wordpress_backup.sql
- Restore the WordPress files. If you want to restore the previously installed plugins, themes or the uploaded files, you can uncompress the backed up tarball that you created previously in the old server:
$ sudo tar -xzvf /home/bitnami/wp-content_backup.tar.gz /opt/bitnami/apps/wordpress/htdocs
- Restore the configuration files. If you have customized the WordPress configuration, restore the Apache configuration file:
$ cp /home/bitnami/wordpress_backup.conf /opt/bitnami/apps/wordpress/conf
Restart the servers with the command below. You should then be able to access your blog in the new instance.
$ sudo /opt/bitnami/ctlscript.sh restart
How do I associate the previous IP address with the new instance?
Once you have checked that the application is running properly and all of the data was successfully migrated, you can associate the old server IP address with the new instance. To do so, go to "Elastic IP's" in the Amazon AWS Console and change the instance associated with it. If you do not have any IP address, you can create a new one:
If you are using BitNami Cloud Hosting, you can either delete the old server (if you made a backup, you will still be able to restore it in the future) or use the "assign IP' button in the Manage section for your server to change the IP of the old server. You will then be able to go to the new server, click on the "assign IP" button and select the old IP address for your new server.
Once it has been updated (note that this sometimes takes a few minutes), you can access the new instance using the same domain name that you were using for the previous instance.