**How to avoid overwriting files during MySQL dump from dev to production import in Strapi with S3?**
#1640
Unanswered
keerthi8632
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to avoid overwriting
filesduring MySQL import in Strapi with S3?Context:
CMS: Strapi v4.25.12
Database: MySQL
Media: AWS S3 using
@strapi/provider-upload-aws-s3Deployment: Jenkins CI/CD pipeline
Issue: During deployment, we import a MySQL dump from the dev environment to production. The dump overwrites the
filestable, causing loss of production media metadata. While the S3 files remain intact, frontend and admin panel media links break due to missing metadata.What We Tried:
Excluding
filestable via--ignore-tableworks but loses new dev media added.Manual sync is unreliable and not scalable.
Goal:
How can we safely import development data without overwriting
filesentries while also syncing new media records (if any)?Ideal Solution: A way to:
Retain existing production media entries
Add new
filesentries from dev without deleting or breaking prod onesIs there a common practice in Strapi + MySQL + S3 setups for this?
Thanks in advance!
Attempted MySQL dump with --ignore-table=files
Command:
mysqldump --ignore-table=mh_website_db.files...
✅ Expectation: Prevent overwriting production media metadata.
❌ Result: Although this preserved existing media, it skipped new media records from the dev environment that we wanted to promote — breaking references to newly added assets.
Tried full dump/import (no ignores)
✅ Expectation: Full environment sync with new content and media from dev.
❌ Result: This overwrote valid production files entries — causing broken media links in the admin UI and frontend due to missing metadata.
Tried manually comparing and inserting missing rows
✅ Expectation: Keep existing production entries and append only new dev media.
❌ Result: Not scalable, hard to automate, error-prone (especially with associations like related_morph),due to primary keys its mismatching in production existing data.
Beta Was this translation helpful? Give feedback.
All reactions