How to Back Up and Restore a Bitnami WordPress Instance on AWS Lightsail (After a PHP 8 Upgrade Breaks Your Site)

If you’ve ever tried upgrading PHP on a Bitnami WordPress instance in AWS Lightsail, you may have learned the hard way that it’s not as simple as running a few commands. In my case, updating to PHP 8 completely broke the WordPress site, and I discovered that AWS Bitnami vps instances are not designed to handle in-place PHP upgrades gracefully.
Because of this, I had to back up the entire WordPress application and database, then migrate and restore everything to a new instance. Below is a step-by-step guide I used, which might save you a lot of time if you’re facing the same issue.
Why PHP 8 Breaks Bitnami on Lightsail
- Bitnami packages everything; Apache, PHP, MariaDB, and WordPress—into a custom stack that is tightly integrated.
- Upgrading PHP independently isn’t supported.
- Attempting to update PHP often leads to broken dependencies and runtime errors.
- The best solution is to migrate to a fresh Bitnami instance with the PHP version you want.
Step 1: Stop Services Before Backing Up
sudo /opt/bitnami/ctlscript.sh stop
Step 2: Back Up WordPress Files
# Full application backup
sudo tar -czvf wordpress-files-backup.tar.gz /opt/bitnami/wordpress
# Just wp-content (themes, plugins, uploads)
sudo tar -czvf wp-content-files-backup.tar.gz /bitnami/wordpress
The second path /bitnami/wordpress
is often a symlink or mount point depending on your stack. It’s good to back up both to be safe.
Step 3: Backup the MariaDB Database
mysqldump -u bn_wordpress -p --socket=/opt/bitnami/mariadb/tmp/mysql.sock bitnami_wordpress > /tmp/backup.sql
Replace bn_wordpress
with your DB user and bitnami_wordpress
with your actual DB name if different. You’ll be prompted for the DB password.
Step 4: Move Backups to the New Instance
scp wordpress-files-backup.tar.gz bitnami@NEW_SERVER_IP:/home/bitnami/
scp backup.sql bitnami@NEW_SERVER_IP:/home/bitnami/
Step 5: Restore Files on the New Server
sudo tar -xzvf wordpress-files-backup.tar.gz -C /
If you only restored wp-content, make sure it’s placed correctly:
sudo cp -r /path/to/wp-content /bitnami/wordpress/wp-content
sudo chown -R bitnami:daemon /bitnami/wordpress/wp-content
sudo find /bitnami/wordpress/wp-content -type d -exec chmod 775 {} \;
sudo find /bitnami/wordpress/wp-content -type f -exec chmod 664 {} \;
Step 6: Restore the MariaDB Database
Make sure the database exists first. When a new Bitnami Wordpress instance is launched, it will use the same db name (bitnami_wordpress). Or you can always create it via:
Note: Be sure to look in the wp-config.php file for the db username and password, below gives the example of root, but this may not be what you use.
/opt/bitnami/mariadb/bin/mysql -u root -p --socket=/opt/bitnami/mariadb/tmp/mysql.sock
CREATE DATABASE bitnami_wordpress;
EXIT;
Now import the backup:
/opt/bitnami/mariadb/bin/mysql -u bn_wordpress -p --socket=/opt/bitnami/mariadb/tmp/mysql.sock bitnami_wordpress < /home/bitnami/backup.sql
Step 7: Restart Bitnami Services
sudo /opt/bitnami/ctlscript.sh restart
Or restart them individually:
sudo /opt/bitnami/ctlscript.sh restart apache
sudo /opt/bitnami/ctlscript.sh restart php-fpm
sudo /opt/bitnami/ctlscript.sh restart mariadb
Step 8: Verify Everything Is Working
sudo /opt/bitnami/ctlscript.sh status
If something seems off, review the logs:
- Apache logs:
/opt/bitnami/apache2/logs/error_log
- PHP logs:
/opt/bitnami/php/var/log/php-fpm.log
- MariaDB logs:
/opt/bitnami/mariadb/logs/mysqld.log
Useful System Info Commands
php -v
cat /etc/os-release
Final Thoughts
Bitnami’s WordPress stack is stable, but it doesn’t support partial upgrades like PHP alone. If you’re on AWS Lightsail and want a newer PHP version, you’re better off:
- Launching a new instance with the desired stack
- Migrating your site cleanly as shown above
This gives you a clean, functional setup without the PHP headaches.