I’m migrating my content from my self-hosted Lightsail instances on Amazon Linux 2 (Ghost version 5.68.0) to Amazon Linus 2023 (Ghost version 5.82.5). I’ve imported my members and looking for guidance on how to transfer the other member information such as Open Rate, Location, Member Activity, and anything else that the import function doesn’t capture.
When I migrated from one host to another, I exported the database, contents folder, routes, and redirects. This resulted in a verbatim copy of the site on the new host.
How do I export the database? It seems like the database structure has changed a little based on the fields that the software had me map to when I imported the members. Should I undo importing the content because the database export will contain everything?
Ideally, upgrade the older instance to the latest version of Ghost. Then you need console access to export the database, and copy the files to the new host. It’s best to start a fresh on the new host.
I’m away from home at the moment, but when I return I can share the steps. Both hosts need ssh and zip. You’ll need to download your theme, routes, and redirects from Ghost admin.
Mjm,
I’ve tried upgrading the older Amazon Linux 2 instance but was not able to because I’m limited by my Node version 16. That’s what led me down this path to upgrade the server to Linux 2023.
Got it. I’ll go ahead and install the 5.68.0 version on the new linux. I would appreciate your steps for migrating the database over when you get home.
mjw,
I’m getting stuck at the install now. When I run the install, it’s asking me for the MySql username and password along with the sudo password. I’ve found the MySql username and password in my old instance’s config json file. But I don’t know what the sudo password is. Is my assumption that all configs and passwords should be replicated from the old to the new instance correct?
Set the sudo password for root and ghost on the new instance
Uninstalled ghost and reinstalled the old version of ghost 5.68.0
Copied the data folder from the old to the new instance
Copied the content folder form the old to the new instance
Copied the config.production.json from the old to the new, but changed the url to my IP address since I have the older server still running under my domain
Restarted the server and the status says apache, ghost, an dmysql are running…
Got it working! The ghost service was failing with the following error:
✔ Checking system Node.js version - found v18.19.1
ℹ Ensuring user is not logged in as ghost user [skipped]
ℹ Checking if logged in user is directory owner [skipped]
✔ Checking current folder permissions
✔ Validating config
✔ Checking memory availability
✔ Checking binary dependencies
✖ Starting Ghost: localhost
A GhostError occurred.
Message: Ghost was able to start, but errored during boot with: Cannot read properties of undefined (reading 'members')
The solution was to run the update sql from this post:
You’ve jumped the gun! :) You should have started by migrating the database, and other resources from the old server to the new.
Is there a specific reason you’re running Apache? The recommended proxy server is Nginx.
This is what I’d do on the old host. Once you’ve copied the database, contents folder, and the config across, please let me know.
# Dump the production database to a file
mysqldump -u root -p database-name > database-name-dump.sql
# Securely copy file to new host
scp database-name-dump.sql user@ip-address:/home/user
# Copy config to new host
scp /var/www/site/config.production.json user@ip-address:/home/user
# Add contents folder to archive
tar -zcvf site-content.tar.gz /var/www/site/content/
# Copy archive to new host
scp site-content.tar.gz user@ip-address:/home/user
Substitute user with your username. Likewise, replace ip-address with the new host’s IP address.
Finally, for this step, download redirects, routes, and theme from the Ghost admin console.
I didn’t choose Apache. When I spun up the new Amazon Lightsail instance with Ghost already installed, Apache was already configured with Ghost.
Thank you for the procedures to migrate the mysql database. I had found similar procedures, but I was unsuccessful in running the mysqldump. When I tried to run the mysqldump, but I kept getting an error so that’s why I resorted to tar-ing up the mysql data directory.
Next thing I have to fix is the broken images. Is there an easy way to do this or do I have to re-upload all the images?
It would be preferable to resolve the error condition than copying the database folder.
This is a bad idea for an InnoDB as you are likely to have mismatched tablespace ids. The correct way is to use mysqldump.
If you copied over the images and restored them to the same folder on the new host, nothing else needs to be done. The fact they are broken implies that the database is broken. I recommend you use mysqldump and resolve the errors, which, I’m guessing, are related to user permissions.