• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Migrate your existing images to S3

lonepress

Chevereto Member
With Chevereto 3.5+, you can add external storage configurations to upload your images to S3. After you enable this, all of your new images will be uploaded to S3 and served from there (or a CDN connected to S3). But what about all your existing images?

Here is a guide to migrating your existing images to S3, so you can remove them from your web host's local disk. This works for both direct and datefolders storage modes.

Before you start:
  • Enable S3 in your chevereto dashboard so that all new images are uploaded to S3. Make sure it's working.
  • Know how to access your web host command line shell.
  • Know how to run SQL commands against your databse (using phpmyadmin is fine).
  • Make sure the AWS command line interface is installed on your web host.
    • run "aws --version" to check
  • Just in case it goes horribly wrong: make sure you have backups of your database and local image files.
Steps:

Shell into your web host. Edit these commands with your web host and S3 configuration values, and run them:

export AWS_ACCESS_KEY_ID=<your access key>
export AWS_SECRET_ACCESS_KEY=<your secret key>
cd <your chevereto web root>/images

# Make sure your credentials are working.
# You should see a list of your S3 buckets:
aws s3 ls

# This command will upload all files in your current directory
# to your S3 bucket. It is OK to run this more than once. It will
# not re-upload files that are already in your bucket.
aws s3 sync . s3://<bucket id> --acl public-read


At this point, all of your images have been uploaded to S3. Now make sure you can access them. In a browser, open a few of your just-uploaded images:

http://s3.amazonaws.com/<bucket id>/<image filename>

The last step is to update your database so chevereto knows to serve the images from S3 instead of your local disk. Before running this SQL command, make sure:
  • You change chv_images to use your database table prefix, if you changed it from "chv_"
  • Your value for <storage id> is probably 1. If you have more than one external storage configuration, change it to use the ID of the correct configuration (from the external storages settings page).
UPDATE chv_images SET image_storage_id = <storage id> WHERE image_storage_id is null;

After you run this, all of your old images will now be served from your S3 bucket. After you've triple checked that everything is working, you can clean up the images/ directory on your web host local disk.

Enjoy!
 
Back
Top