GenXJamerican.com Moves to Amazon Lightsail, A Follow-Up

One change I missed after migrating to Lightsail, was ensuring that all the posts with images in them were displaying those images on the new site the way they were on the old. A scroll backward through previous posts revealed the problem quickly enough, but life is busy so it took awhile until I had enough time fix it. The steps I expected I would need to take to resolve the missing images issue were roughly the following:

  • Start up the old EC2 instance
  • Download the old images
  • Upload the old images to the new instance on Lightsail

Because I only stopped the previous EC2 instance instead of terminating it, I was able to re-start it. To download the old images, I’d have to find them first. Having self-hosted WordPress for awhile, I knew the images would be in subfolders under wp-content/uploads, so the only real question remaining was where exactly the old Bitnami image rooted the install. Once I “sshed” into the instance, that location turned out to be ~/stack/apps/wordpress/htdocs/wp-content/uploads. Images were further organized by year and month of blog posts. To simplify the downloading of old images, I had to knock the rust off my usage of the tar command. Once I’d compressed all those years of images into a few archive files it was time to get them off the machine. I used this Medium post to figure out the right syntax for my scp commands.

Once the archive files were on my local machine, I needed to get them onto the Lightsail instance (and expand them into its uploads folder). But just as I did compressing and pulling the files down from the EC2 instance, I had to figure out where they were in the new Bitnami image. As it turned out, the path was slightly different in the Lightsail image: ~/stack/wordpress/wp-content/uploads. Once I uploaded the files with scp, I had to figure out how to move them into the years and months structure that would match my existing blog posts. Using the in-brower terminal, I was reminded that the tar command wouldn’t let me expand the files into an existing folder structure, so I created an uploads-old folder and expanded them there. Then I had to figure out how to recursively copy the files there into uploads. It took a few tries but the command that ultimately got me the result I wanted was this:

sudo cp -R ./uploads-old/<year>/* ./<year>

Now, every post with images has them back again.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.