Migrating away from Local Storage

So I was deploying a bunch of small Ghost sites using Kubernetes and just using Local Storage, because I figure if I already need local storage to upload Themes, why not use it for images (these are small sites). This also made them super modular and I loved that; however, using Kubernetes from DigitalOcean I can only have 7 local storage modules per node in the cluster, and when you factor in redundancy, that means only 3 realistically per node making it super expensive to run.

So how can I migrate away from local storage? I’m going to deploy clustered MySQL and use S3 (DigitalOcean spaces) for media storage but I still would need some for the theme. I was hoping I could just deploy but then I’d have to copy the theme into the container every time and I’m not super fond of that idea as I want to still be able to upload themes to the folder.

I need to figure out these two problems:

  1. How do I migrate images from local storage to S3
  2. How do I handle the theme files?

Thanks

Ghost supports custom storage adapters - here’s the docs on them: https://ghost.org/docs/concepts/storage-adapters/, it should be enough to get you going :relaxed:

Hi Fabien,

Yes I know it supports storage adapters, that’s what I’m trying to figure out though is how to move existing content from the local storage adapter to the S3 storage adapter. Also the storage adapters do not hold the theme right?

Hey!

Sorry I misunderstood your question! In order to migrate the content from the local storage adapter to the S3 storage adapter, you’ll need to write a custom script for that. (Unless the s3 storage adapter repo contains one already)

Yes you’re right that currently the storage adapters do not hold the theme. The reason for this is that theme files are potentially read on each request - and connecting to S3 to download multiple files per request will have a significant perf hit!

To expand on the script, you’ll need to go through all your locally stored images, and pass them to be uploaded by the s3 storage adapter. You’d then need to make sure all the URL’s referenced in the database have been updated!

Depending on the size of the sites it might be quicker to switch storage adapter, and then upload manually the images