IT9 FELIX blog

Migrate WordPress site to different AWS account (PART 2 – RDS DB Migration)

To migrate the RDS from one account to another, you may:

1). Take a snapshot

2). Share the snapshot to the target AWS account

3). Restore the snapshot on the target AWS account

*Auto-back (auto-generated) snapshots cannot be shared

To create a snapshot:

1). Go to RDS service -> “Databases” -> choose the DB you want to migrate -> “Action” -> “Take Snapshot”

 

2). Name the snapshot image and then “Take Snapshot”

 

3). The created snapshot can be found on “Snapshots”. It may take a few minutes to become available.

 

 

4). Once the snapshot is available. select the snapshot -> “Action” -> “Share Snapshot”

 

5). Keep the snapshot private (Not disclosing it to other AWS users) & fill in the target AWS Account ID -> “Add” -> “Save” to apply the permission settings

 

6). Now the snapshot is shared to the target AWS account. Log onto that AWS Account -> Go to “RDS” -> “Snapshots” -> Under the filter “Shared with Me”, you will see the shared snapshot

 

To restore the snapshot on the target AWS account:

1). Select the snapshot -> “Action” -> “Restore Snapshot”

 

2). You cannot assign different DB Engine, Licence Model, etc. However, you may do it by choosing “Migrate Snapshot” instead of “Restore Snapshot”

Restore Snapshot: Cannot choose other DB Engine but only the one of the snapshot

 

Restore Snapshot: CAN choose other DB Engine which is compatible to the one of the snapshot

 

3). Restoring the snapshot is more or less the same as creating a new DB via RDS. However, the data in the snapshot is retained together with the DB settings (e.g. DB name, Admin settings, Password, etc).

RDS DB Migration is completed with just a few steps and clicks included, as simple as that~  🙂

 

Connect the previously create EC2 instance (web server) to the new DB host instead of the old one:

It can be done by updating the wp_config.php file.

1). Log onto the EC2 server via SSH as root user (by typing the command “sudo su”)

The config file sites at the web folder of your wordpress site (e.g. /var/www/html)

 

2). if you couldn’t find the file, you may do the file search using the command:

find . -name wp-config.php

It searches the file recursively based on the current directory. Locate the file & edit it

(Linux command: “vi wp-config.php”)

 

3). Inside wp-config.php, find the keyword: “MySQL hostname” -> Update the host name to the new DB instance endpoint (You may find the endpoint value of your RDS server on AWS RDS)

(e.g. xxxx-rds.xxxxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com)

 

4). Paste the value in wp-config.php then save & exit

 

5). DONE, the newly migrated WordPress site is now pointing to the new migrated DB server 🙂

 

Previous -> Part 1 (Migrate EC2)

Next -> Part 3 (Create the new SSL Cert)

Leave a Reply

Your email address will not be published. Required fields are marked *