Data get's deleted when strapi container restarts

@Eventyret images are saving in media library after uploading .

@Eventyret i am facing this issue when i am hosting strapi on ecs using ecr through docker image .

even im facing this issue

So most of the time when people get this issue, it’s one of the following scenario:

You are running docker with development and using sqlite. To fix this make sure you are running it with production and not development Also make sure your config folder has two settings, 1 for development 1 for production.

The important thing here is, if you are using sqlite in development, when you restart the container the sqlite is deleted and recreated. Meaning you loose the data.

The data should not just delete itself.

When it comes to images not saving, it’s kind of the same scenario, but you need to bind-mount the public folder on the server so you have persistent storage. It’s recommended when using docker to not use bind mounts, rather use a upload service like cloudinary, S3 etc. to store your uploads.

This issue still persist.
I’m using PostgreSQL as database on both Mac and Ubuntu.
I don’t have any docker environment set, nor something custom outside Strapi defaults.

In my case all relations and role settings are deleted in development.
Every time I run the development environment I have to re-set all the relations again and again.
I’m currently using Strapi 4.7.1 and the issue exists from version 4.6.0 onwards.

1 Like

Have you tried 4.8.1 ?
Seems they did some fixes

@Eventyret I haven’t yet, I didn’t even know that there is v4.8.x available :slight_smile:

Thanks for the update, I will check it.

We’re facing the same issue. Random parts of data dissappear. It’s not whole tables, just some fields, and the config part of fields. For example, when we make changes to the Content Type layout, some fields lose the config, and the content disappears as well.

We’ve had it happen 3 times in the past 4 months!!! Absolutely unacceptable. We are 100% using Postgres DB, both the DB and Strapi are hosted on Heroku. We’re using NextJS on Vercel to pull the data from Strapi and build a static site, but random parts of data disappear.

We’re even lost some images on some content types, but when I go check the files_related_morphs table, I can still see all of the images related to content types there, but it doesn’t appear in the Content Editor nor the API…

Horrible. Never using Strapi for production sites again in the future.

1 Like

Thank you for your feedback :pray: @gmenih
One question I have is regarding your images. What type of provider are you using to upload images?
Are you using local upload provider by any chance ? :slight_smile:

No, we’re using the S3 provider.

@Eventyret I can confirm same as @gmenih that random data are disappearing.
I’ve got v4.8.2 installed, and now not just table relation data, but also columns from the schema are missing.

1 Like

We had the same issue happen today where the article and users table were deleted.
We’re using postgres. Seems to have happened while editing articles via the admin.

Using postgres at DO. Netlify frontend. 4.7.1

Crazy this can happen.

Exactly same problem here. I restarted strapi a boom, deleted some important data from some tables (not all of them). What I did was ) update @strapi packages to latest versions, also add a strapi-google-cloud-storage plugin. I can not track what action triggered this deletion but still is super bad, really annoying and basic behavior for CMS, not to delete data without a confirmation at least.

STRAPI VERSION
v4.10.1
It happened again.

Container restarted and some, but not all, data disappeared.

Same for me, latest content type I’ve created experienced data loss, three times in three days.

Are you using a shared database, or sqlite.

I’m facing the same problem tool.
I’m using MySQL database and PM2 as Webserver.

PM2 version 5.3.0
Strapi version 4.11.5
Node version v16.20.0

The issue is still present, I’ve commented previously with v4.8 that issue was resolved, but now it had happened in production again.
I’m using heroku, and I’ve just added a new config variable to the docker that has nothing to do with Strapi at all, and all data were removed, whole database (postgres) wiped out.

1 Like

The same here.

Postgres, docker & K8S for production.

Losing some data on each reboot ( no problème with old version 3.6.9 ).

Moreover :
-When I make a dump from K8S to my local strapi, 80% of data is losse too.
-CKEditor plugin data is always loose.

We are very affraid about that, we work for a government project…

Please, there is a fix soon or someone work on it ?

Thanks in advance

As been stated many times.
If you have this issue please do post your database.js or if you have multiple environments. config/ENV/X/database.js etc

Also check that when strapi starts it does not say sqlite. As strapi won’t just delete data but mostly it’s miss configured config.
A container does not hold any data so using a sqlite file will result in dataloss. Hence why this is most likely the reason people are experiencing the issue.

Please, there is a fix soon or someone work on it ?

Please check what I said below.