Skip to content

[Bug]: strapi import silently deletes cloud provider assets without warning #2995

@axelabtion

Description

@axelabtion

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 import deletes 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, running strapi import on 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

  1. Set up two Strapi instances (e.g. production and staging) pointing to the
    same cloud storage account.
  2. Upload some files on the staging instance (these will not exist in a
    production export).
  3. Run strapi export on production to create an archive.
  4. Run strapi import -f export.tar.gz.enc on staging.
  5. 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 files or ensure each environment uses an isolated storage
bucket/account.

Related issue(s)/PR(s)

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions