-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Link to the documentation page or resource
https://docs.strapi.io/cms/data-management/import
Describe the bug
Summary
The strapi import command, when run against a Strapi instance using a cloud
storage provider, permanently deletes files from the cloud provider for any
media records that exist in the destination database but are not present in the
import archive. This behavior is not documented and results in irreversible
data loss on the cloud provider.
Current documentation warning
The import page states:
"
strapi importdeletes all existing data, including the database and uploads
directory, before importing the backup file."
This warning only references the local "uploads directory" and gives no
indication that cloud-hosted assets will be deleted via the provider's API.
Impact
- If two environments (e.g. staging and production) share the same cloud
storage account, runningstrapi importon one environment with an export
from the other will delete any files that were uploaded after the export was
created — permanently removing them from the shared storage and breaking
assets in all connected environments. - There is no dry-run option, no confirmation prompt specific to cloud assets,
and no way to recover deleted files unless the cloud provider offers its own
backup or versioning feature.
Steps to reproduce
- Set up two Strapi instances (e.g. production and staging) pointing to the
same cloud storage account. - Upload some files on the staging instance (these will not exist in a
production export). - Run
strapi exporton production to create an archive. - Run
strapi import -f export.tar.gz.encon staging. - Observe that the files uploaded in step 2 are permanently deleted from the
cloud storage provider, even though both environments shared the same
account.
Environment
- Strapi version: v5
- Storage provider: third-party cloud upload provider
- Deployment: cloud-hosted
Additional context
No response
Suggested improvements or fixes
Expected behavior
The ideal fix would be a behavioral change: strapi import should not
delete remote assets for cloud storage providers unless explicitly
instructed to do so via a flag such as --delete-remote-files. Deleting
records from the local database and deleting files from a remote cloud provider
are two fundamentally different operations — the latter should always require explicit opt-in.
At a minimum, the warning box on the documentation for the import page should be updated to include:
If you are using a cloud storage provider (e.g. Cloudinary, AWS S3, Azure
Blob Storage, Google Cloud Storage), any media files whose database records
are removed during import will be permanently deleted from the cloud provider
via its delete API. This affects all environments sharing the same cloud
storage account. To avoid unintended deletion of remote assets, use
--exclude filesor ensure each environment uses an isolated storage
bucket/account.
Related issue(s)/PR(s)
No response