aws

Upgrade an AWS instance

This guide describes the general process to upgrade from an older Bitnami Amazon Machine Image (AMI) version to a newer one. You can also follow these steps to switch to an AMI with a different operating system or version.

Application-specific guides for the most popular Bitnami applications are listed below:

Before beginning the upgrade process, we recommend making a backup of your current instance. While this is not strictly required and you will not actually be applying updates to your current instance, we still recommend making a backup before beginning any procedure. To do so:

  • Connect to your instance.

  • Make a backup using the AWS snapshot feature.

Step 1: Backup files

First, create a backup of the files on the instance. To do so:

  • Connect to the instance as explained in the FAQ.

  • Create a backup of the MySQL or PostgreSQL database.

    • For MySQL, issue the following command (replace wordpress with the name of your application, such as drupal, redmine, etc.):

        $ mysqldump -u root -p bitnami_wordpress > /home/bitnami/wordpress_backup.sql
      
    • For PostgreSQL, issue the following command (replace wordpress with the name of your app, such as drupal, redmine, etc.):

        $ pg_dump -U postgres bitnami_wordpress > /home/bitnami/wordpress_backup.sql
      
  • Create a backup of any uploaded images, themes and plugins. This depends on the application itself. For PHP applications (Drupal, Wordpress, Joomla! and others), replace wordpress with the app name and wp-content with the name of the file where the data is saved):

      $ 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 the application is configured to run at the root URL, copy the configuration files of PHP or Ruby applications with the following command:

      $ cd /opt/bitnami/apps/wordpress/
      $ sudo tar -czvf /home/bitnami/conf_backup.tar.gz conf
    
  • 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 use the scp command to download them or use an SFTP client. For this tutorial, use the SCP command-line:

      $ scp -i /path/to/private_key.pem bitnami@old_server:/home/bitnami/wp-content_backup.tar.gz .
      $ scp -i /path/to/private_key.pem bitnami@old_server:/home/bitnami/conf_backup.tar.gz .
      $ scp -i /path/to/private_key.pem bitnami@old_server:/home/bitnami/wordpress_backup.sql .
    

    You can also send files from the old instance 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/private_key.pem
    

Step 2: Move the data to the new instance

  • Start the new version of the Bitnami AMI.

  • Upload the files to the new instance. To upload the database backup and files downloaded earlier to the new instance, use the scp command as shown below:

      $ scp -i /path/to/private_key.pem wordpress_backup.sql wp-content_backup.tar.gz conf_backup.tar.gz bitnami@new_server:
    
  • Restore the database and other files on the new instance:

      $ mysql -u root -p bitnami_wordpress < /home/bitnami/wordpress_backup.sql
      $ sudo tar -xzvf /home/bitnami/wp-content_backup.tar.gz -C /opt/bitnami/apps/wordpress/htdocs
      $ sudo tar -xzvf /home/bitnami/conf_backup.tar.gz -C /opt/bitnami/apps/wordpress
    
  • Restart the servers:

      $ sudo /opt/bitnami/ctlscript.sh restart
    

Step 3: Move the IP address

Once your new instance is up and running with all the files restored, point the old instance’s IP address to the new instance.

Last modification September 6, 2018