Backing up Magento Open Source without setup:backup

A practical plan for replacing the deprecated built-in Magento Open Source backup with database and file backups that include code, media and env.php, verified by restores on a separate environment.

On this page

Why Magento Open Source backup strategy starts without setup:backup

A backup strategy for a self-hosted Magento Open Source store starts by listing the four parts that the built-in setup:backup command bundled together: the database, the code, the media directory and app/etc/env.php. Each part needs its own copy and its own schedule. The database holds orders, customers and catalog data, so it usually changes most often and needs the most frequent dumps. Code can be rebuilt from version control and the composer.lock file, but only if the deployed tree matches what was committed, so check for local edits to core files and custom modules. The media directory holds product images and other uploads that live outside the database. The env.php file holds database connection details and the encryption key, and a restored store cannot decrypt stored secrets without the key that matched its database. Store env.php in a restricted location, since it contains credentials.

Timing depends on the release line you run, because the version sets how long you can keep patching before a larger move. Adobe's lifecycle policy gives each 2.4.x release three years of standard support from general availability, with end of regular support on August 11, 2026 for 2.4.6, May 31, 2027 for 2.4.7, May 31, 2028 for 2.4.8 and May 31, 2029 for 2.4.9. Adobe's upgrade guide recommends upgrading every patch cycle to stay secure and PCI compliant, so each patch is a point where the backup set should be fresh and tested. Before any upgrade, take a full set, restore it to a separate environment with the same PHP and database versions, and confirm the storefront loads and admin login works. Confirm your exact version with your team before setting dates.

Backup approaches by environment and team

On a single server, one host runs the web server, PHP, the database, and often Redis, OpenSearch and RabbitMQ. A backup of this layout can usually be taken from one place, but it still has to cover several separate pieces. The database holds orders, customers and configuration. The application tree holds the Magento code, custom modules and themes. The pub/media directory holds product and catalog images, and app/etc/env.php holds database credentials, cache settings and the encryption key. Losing the encryption key makes some encrypted stored values unreadable even when the database restores.

  • Database dump: a logical or physical copy taken with the database engine's own tools, taken at a consistent point.
  • Code tree: the deployed application directory, including custom modules, themes and composer.json with composer.lock.
  • Media and generated files: pub/media and any media directories your extensions write to.
  • env.php and related config: app/etc/env.php and any separate secrets files, stored with restricted access.
  • Search and queue services: these usually rebuild from the database, so confirm whether you need their data or only their configuration.

Confirm with your own administrator which of these your hosting provider already snapshots and whether those snapshots are consistent with the database.

Backup options and when each fits

This table compares the backup components and methods a Magento Open Source store needs, what each one captures, what it misses and the situation it fits. Read it as a set: no single row covers the database, code, media, env.php and the server configuration together, so most stores combine several.

OptionWhat it captures and missesWhen it fits
Database dumpCaptures orders, customers, catalog data, CMS content and configuration rows. Misses code, media files, env.php and anything outside the database.Every store, as a minimum. Pair it with file backups so the database can be restored to match the code version.
File snapshot of codeCaptures the installed codebase, custom modules, themes and composer.lock. Misses the database, pub/media contents and secrets stored outside the tree.Stores that build from a pipeline cannot rely on this alone, but it speeds restore of the exact release running in production.
Media directory backupCaptures product images, category images, WYSIWYG uploads and other pub/media content. Misses database records that point to those files.Catalogs with large media libraries, where media changes often and needs its own retention schedule.
env.php and auth materialCaptures database credentials, cache and session settings, crypt key and admin configuration. Misses everything else, and the file must be stored with restricted access.Required for every restore. Losing the crypt key in env.php can make encrypted database values unreadable, so confirm the key is stored separately.
Volume or disk snapshotsCaptures the whole server or volume at one point in time, including the database files if the database is on the same volume. Misses consistency guarantees unless the database is quiesced or the snapshot is coordinated.Single-host or virtual machine deployments where the operator wants one restore point. Confirm with the storage vendor how snapshots are made consistent.
Off-site copyCaptures copies of any of the above in a second location or account. Misses protection against errors that replicate automatically, such as a bad delete synced to the copy.Any store that must survive loss of the primary site or cloud account. Keep retention and access separate from the production account.
Configuration in version controlCaptures custom code, theme files, deployment scripts and reviewed configuration changes. Misses transactional data, media, and any setting changed in the admin without being exported.Teams that release through Git. It shows what changed and when, but it is not a substitute for a database backup.

How to set up a backup routine that you can restore

This sequence produces a backup routine for a self-hosted Magento Open Source store that covers the database, media, code and env.php, runs on a schedule, keeps copies off the server, and proves that a restore works on a separate environment.

  1. Inventory paths, services and versions

    The operator lists everything the store needs to run: the Magento root directory, the pub/media and var directories, app/etc/env.php, custom modules and themes, the database, search, Redis or Valkey, RabbitMQ and any Varnish configuration. Next, they confirm the PHP, MySQL or MariaDB, OpenSearch and other versions against the Adobe system requirements for the release actually installed, not the release planned. The step is done when the inventory is written down, reviewed by someone other than the author, and every item has a named owner and a location. Ask your DeployOpen or in-house team to confirm which paths are generated and can be excluded.

  2. Schedule database and file backups separately

    Create one scheduled job for the database dump and another for files, so each can be retried and restored on its own. The database job should use a consistent dump method for the engine in use, and the file job should cover code, media and configuration while excluding regenerable folders such as generated code and cache, after checking that exclusions match the inventory. Set the crontab entry under the account that owns the Magento files so permissions are preserved. The step is complete when both jobs have run at least once manually and produced archives with timestamps and sizes that match the expected content.

  3. Protect env.php and its encryption key

    The file app/etc/env.php holds database credentials, cache and session settings, and the encryption key that Magento uses to protect stored secrets. Back it up as its own artifact with restricted read permissions, and store it apart from the general file archive so access can be limited to the people who handle recovery. Record which key is in use and where it is kept, because a database restored without the matching key can leave encrypted configuration values unreadable. The step is verified when the team can state the storage location and access list for the key, and a test decrypt-and-read of a known setting succeeds on the restore environment.

  4. Store copies off the server

    Send each database and file archive to storage that is separate from the store host, such as object storage or a backup system in another account or data center that you control. Encrypt archives in transit and at rest, apply retention rules that match your recovery and compliance commitments, and keep at least one copy that the production server's credentials cannot delete. The step is complete when a listing from the off-server location shows the latest archives, and a checksum of a downloaded copy matches the checksum recorded at creation.

  5. Record checks after each backup run

    Have the job write a log entry and a short report for each run, covering start and end times, exit status, archive sizes, checksums and the off-server upload result. Set an alert that reaches a person when a run fails or produces an archive far smaller than the previous one. The step is verified when a deliberately failed run, such as one with a wrong path in a test copy, triggers the alert and appears in the report.

  6. Restore to a separate environment

    Restore the latest database, files and env.php to a non-production environment built from the same release, PHP version and service versions as production. Run the Magento setup and cache steps your runbook defines, then load the storefront, sign in to the admin, place a test order in a sandbox payment mode and confirm that media and custom modules work. The step is done when the restored environment passes these checks and the time taken and any manual fixes are recorded in the runbook.

  7. Repeat restore tests on a schedule

    Set a recurring restore test, and rerun it after any change to the Magento version, PHP or database engine, extensions, storage layout or backup scripts. Compare each test with the previous record so that drift shows up early, such as a missing module or a new large directory that the inventory does not list. The step is complete when the schedule, owner and pass or fail history are stored with the runbook, and any failed test has a documented fix and a retest.

How backup components flow to a separate restore environment

The flow starts in the production store, where the database, code, media, env.php and the encryption key are captured as separate artifacts. Each artifact crosses a trust boundary into the off-site backup store, and the key is kept apart from the data it protects. A scheduled restore pulls the set into an isolated test environment, where a verification step checks that the store runs and the data is complete. Check that the key and the backup store sit under different access controls than production, and that the restore loop runs on a regular schedule.

Backup artifacts cross a trust boundary and are restored and verified in isolation.

Protecting backups that hold customer and payment-related data

A Magento backup is a full copy of customer records, order history, admin accounts and the secrets needed to run the store. The cards below cover the controls that keep those copies from becoming the weakest point of the store, and each one should be confirmed with your PCI DSS assessor against your own scope.

Access control to backup storage

Backup storage is often less restricted than the production database, yet it holds the same customer data. Limit read and restore rights to a named set of operators, separate the people who create backups from the people who can restore them, and keep backup buckets or volumes out of general file share access. Review these grants on a fixed schedule and after staff changes. Confirm with your assessor which role model you need for backup administration.

Encryption of dumps and archives

Database dumps and tarballs of pub/media and var can contain card-adjacent data, customer addresses and hashed credentials. Encrypt them at rest with keys held outside the backup store, and encrypt them in transit when they move to a second site. Test that a restore works with the encryption key path your team actually uses, because an unreadable archive is no backup. Ask your provider how the encryption is performed and where keys are kept.

Handling env.php secrets and the encryption key

The app/etc/env.php file holds database credentials, the cache and session configuration, and the key Magento uses to encrypt stored values. A backup without this key can restore data that the store can no longer decrypt, while a backup that exposes it exposes everything else. Store the key copy in a separate secrets vault with its own access list, and restrict who can read archived env.php files. Confirm the rotation and recovery steps with your team before an incident.

Retention and deletion

Keeping every backup forever extends the number of places personal and payment-adjacent data lives, which widens your PCI DSS and GDPR footprint. Set separate retention periods for daily, weekly and monthly copies, and document the rule that removes expired copies from every location, including off-site and cold storage. Ask your legal and compliance team how long order and customer records must be kept, and make sure backup retention does not silently exceed that period.

Logging of restore access

A restore replays production data into an environment that may have weaker controls, so every restore should leave a record. Log who requested the restore, which backup set was used, where it was restored and who accessed the result. Keep these logs outside the store's own admin logs so they survive an incident on the store. Confirm with your security team where these records are stored and how long they are retained.

Payment data scoping under PCI DSS review

Backups extend the systems in scope for PCI DSS. If the store stores, processes or transmits cardholder data at any point, backup copies of those systems may be in scope too. Keep the store on a hosted payment page where possible so that card numbers are not in the database, and verify that no dump or log captures card data. Confirm the scope boundary, including backup locations, with your Qualified Security Assessor before you finalize the design.

How to test restores on a separate environment

A backup is unproven until someone has restored it onto a separate environment and confirmed the store works afterward. Archives that complete without error can still be missing app/etc/env.php, carry a database dump that does not match the media folder, or depend on a PHP extension the new server lacks. Treat each restore test as the only real evidence that your backup strategy works, and record what was restored, from which backup set, and by whom.

Build the test environment on the same Magento Open Source release line and PHP, MySQL or MariaDB, OpenSearch, Redis or Valkey, and RabbitMQ versions as production. Adobe's system requirements for your release list the supported combinations, and Adobe supports only those combinations, so a mismatched test server proves little. Restore the code archive first, then the database and media, then env.php, and confirm the encryption key and database credentials in env.php match the restored database. Keep the test environment off public DNS and disconnect it from payment gateways, ERP connections and email sending so a restored copy cannot place orders, push stock or message customers.

After restore, check that the storefront loads, the admin login works with a known account and that orders, customers, catalog and media files are present and linked correctly. Run the setup and indexer commands needed to rebuild indexes and caches, then confirm the indexers return to a ready state and that cron and queue consumers start cleanly. Repeat the test on a schedule your risk assessment supports, and after any change to the platform, extensions or storage layout. Measure restore duration each time instead of relying on an estimate, because database size, media volume and indexing time vary by store, and ask your hosting provider or partner to confirm recovery targets in writing.

Limits to confirm in your environment before relying on the plan

A backup plan is only as good as the assumptions behind it. The cards below list the facts about your installed release, cache layers, search and queue state, file storage and business rules that decide whether a restore returns a working store.

Installed release and support end date

Confirm the exact 2.4.x release and patch level you run, then check its end of regular support in Adobe's lifecycle policy. A backup taken on a release that has left support still restores that release, so the plan must include the upgrade path, not just the copy. Record the version in the backup manifest so a restore target matches the source.

Lifecycle policy

Varnish and other cache layers

Full-page cache sits outside the database and the app/etc and pub/media directories, so a restore does not bring it back. Confirm whether Varnish is in front of your self-managed store and whether it needs a purge or warm-up after a restore. Cache contents are rebuilt, not backed up, so plan the first hours after recovery around that.

Varnish cache guide

Search engine and index state after restore

Your search engine holds its own index, which the database backup does not contain. After a restore, check whether OpenSearch or the engine you use needs a reindex and whether indexers are marked as valid or invalid in the database. Test a sample of product searches and category pages on the restored environment before you call the restore complete.

Queue state and pending messages

Message queue tables and any messages held by RabbitMQ are part of the live state at backup time. Confirm which consumers were running, whether messages were in flight, and whether a restored store should replay or discard them. Missing or duplicated orders and emails are the usual result of skipping this check.

Multi-node file sharing

If your web nodes share pub/media, var or session storage through a network mount or object store, a single-node file copy will miss data held elsewhere. Confirm where each path lives, which node runs cron, and whether the backup job captures every shared location. Test that a restored node serves images and sessions without manual copying.

Third-party extension data and retention period

Extensions can store data in custom tables, files and external services that a generic backup misses. Inventory extension data stores and their owners, and ask the business how long backups and their logs must be kept, who approves restores, and where copies may be stored. Those answers set the retention schedule and the restore test frequency.

Questions buyers ask about Magento Open Source backups

What does a Magento Open Source backup and restore project cost?

No price is published for this work, and a fee depends on the written scope. The main cost components are the time to inventory the store, configure database and file backups, set retention and encryption, script the restore, and run a restore test on a separate environment. Costs rise with database size, media volume, the number of storage locations, and whether backups must meet your own retention or residency rules. Ask for a quote that separates one-time setup from recurring work, such as monitoring backup jobs, rotating test restores and reviewing retention each time the store is upgraded.

How long does a backup and restore test take to set up?

Duration depends on what has to be covered and how quickly the inputs arrive. The factors that set it are the number of sites and store views, database size, the volume of the pub/media directory, how many storage targets are involved, and whether a separate restore environment already exists. Access to cloud accounts and to the team that owns the server also affects the schedule. Ask the provider to state the timeline in the written scope, along with the point at which a full restore has been proven on the separate environment.

What does our internal team need to provide for the project?

The team needs to supply access and facts that only it holds. Typical inputs include:

  • Hosting and storage account access, with a named owner for each backup target
  • The current Magento Open Source version, PHP version and database engine, so the backup tooling matches the environment
  • Location and ownership of app/etc/env.php, pub/media, custom code and any var data the store relies on
  • Recovery time and recovery point expectations agreed by the business, plus a restore environment that can be used for tests

Missing any of these usually adds discovery time to the project.

Can our own staff set up Magento backups without an outside partner?

Yes, a capable operations team can build backups in-house, provided it has someone who understands Magento's file layout, database dependencies and deployment process. The areas most often underestimated are secrets handling, consistent database and file snapshots taken at the same point, and restore steps that have been rehearsed. Ask whether your team can answer these before deciding: where the encryption key lives, who can read the backup, how a restore is performed on a clean server, and how long the restore has taken in a test. If those answers are unclear, an outside review of the design is a cheaper way to fill the gap than an incident.

How should we protect env.php inside our backups?

Treat app/etc/env.php as a secret, because it holds database credentials, the encryption key and cache and session settings. Back it up separately from the general code archive, encrypt it at rest, restrict read access to a small group, and store the key outside the backup it protects. Do not place it in a public repository or a shared bucket. Confirm with your own security team how the file is rotated after a restore, since the encryption key must match the data it protects. Your hardening review should cover the same file for the live store.

How is a restore test different from simply having backups?

A backup only proves that data was written somewhere. A restore test proves that the store can be rebuilt from that data on a separate environment, with the code, media, database and env.php matched to one point in time. The test should start on an empty server, run the documented steps, reconnect search, cache and message services, and confirm the storefront and admin work. Record how long it took and what needed manual intervention. Repeat the test on a schedule, and after any change to storage, Magento version or hosting, because an untested backup often fails at the step nobody rehearsed.

What changes in our backups after a Magento upgrade?

An upgrade changes what must be captured and how the restore is verified. Adobe's upgrade guide recommends upgrading every patch cycle to stay secure and PCI compliant, and names customizations, extension count, third-party integrations and coding practices as drivers of effort. After each upgrade, confirm that the backup still includes the new code tree, any added modules, the updated PHP and database versions, and the search and queue services that the release requires. Run a restore test against the upgraded version before relying on the new backup. The Upgrade Compatibility Tool, referenced in the upgrade guide, can help identify code that will need attention.

How DeployOpen scopes and supports backup and restore work

DeployOpen agrees the backup scope in writing before any configuration starts. The written scope names the store components to protect: the database, the pub/media directory, custom code under app/code and app/design, the app/etc/env.php file and any auth.json or other secrets held outside the repository. It also records the recovery point objective and recovery time objective the business has agreed, which Magento does not set for you, the storage location and retention rules, and who holds the decryption keys. Most engagements are fixed-scope, so the deliverables, the restore test environment and the acceptance criteria are settled before work begins. Ask for a quote that lists each of these items separately, because the cost of a backup job is driven far more by data volume and retention than by the tooling.

Delivery happens inside the client's own infrastructure, on the client's accounts. DeployOpen configures the database dump and file snapshot jobs, the encrypted transfer to storage the client controls, and the scheduling that keeps the database and files consistent with each other. It then runs at least one full restore into a separate environment that does not share credentials or network paths with production, and records the elapsed time and any manual steps. The runbook covers who starts a restore, how to rebuild env.php and the Composer state, how to run bin/magento setup:upgrade and cache flushes afterward, and how to confirm that the restored store takes orders. Retainers can add scheduled restore drills, monitoring of backup job results and help when the store changes platform version. Confirm with the client's security team how restore access is approved, since a restore copy holds customer data.

DeployOpen prepares evidence but does not certify it. The restore records, retention settings and access logs that come out of this work can support a compliance review, but DeployOpen does not issue audit reports, attestations or certifications. Independent assessors perform formal reviews of backup controls against the frameworks that apply to the business. Before starting, ask the assessor which evidence formats they accept and whether they want to see a restore test performed within a stated period.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.