How to work with Strapi without loosing data?

I can only describe how we work during development; however, we couldn’t find the best / optimal way to roll out / deploy to productions when you use cluster (meaning more than one instance of STRAPI).

During development, we use GitHub (private repository - with two types of Github actions.

  1. for development server
  2. for production server (use as a template to roll out changes)

On strapi side, we installed strapi-plugin-config-sync .

Challenges we are facing and current solutions (not the best)

Issue 01 Versions:

The schema of a major collection needs to be changed

Solution:

Create a new strapi cluster named it vXX and migrate data.
Reason:

  • The main reason: Avoid data loss when applying changes to collections.
  • Allowing front-end developers to test and adopt changes without critical downtime.

Challenges

  • Long process
  • Need to manage multiple servers and databases
  • required sysadmin (this depends on how your infrastructure is maintained)

Issue 02 adding fields:

As long as it does not change the schema

Solution:

We are using strapi-plugin-config-sync & strapi-plugin-import-export-entries more than we are using strapi cli

Challenges

  • All our media files installed externally on CDN we must avoid mismatch of data

Media files are our biggest issue. In our case, some of them are attached to a user, not just images for the website.

Issue 03 media files:

The biggest challenges we are having.

Solution:

  • The first step was to modify/expand the original connector to AWS to support saving in folders
    /ec2-bucket/year/month/[sec/hour/day]/filename see: provider-upload-aws-s3-extended. This solution helped to keep the AWS S3 database short and allow to query and write was script to ready s3 to resync back strapi
  • The rsync is done externally by using batch and only in case of emergency.
  • We handle large amounts of media files, and scanning the S3 folder with 6-figure files takes a long time. Splitting it into folders helped to keep it low-numbered.

It Would be nice to see this feature part of the standard strapi and avoid handling one more plugin.

UNDER TESTING - MEDIA SOLUTIONS:

We are currently testing the following options:

  • Use external solutions for media files instead of strapi.
  • Use a dedicated strapi instance only for media and create a custom field using this server. preferred method

Final word:
the challenges we face are no different from any other large environment we used before strapi.
Databases, media, and schema are ongoing issues. Only a working procedure can solve them.

Let us know if this set of highlighted guidelines helped or if you have different suggestions :slight_smile:

2 Likes