Magento 2新手咨询:无需维护模式执行备份是否可行?
Hey Sajid, great question! The short answer is yes—you can absolutely perform Magento 2 backups without turning on maintenance mode. Below are the two main methods to do this, plus key tips to keep in mind:
1. Manual Backup via Command Line
This is a flexible option if you want to run backups on-demand or script them for daily execution. All these commands work without enabling maintenance mode:
- Backup only the database:
bin/magento setup:backup --db - Backup code and media files (excludes database):
bin/magento setup:backup --code --media - Full backup (database + code + media):
bin/magento setup:backup --db --code --media
Note: While maintenance mode isn't required, database backups may briefly lock tables during the process. For this reason, it's best to run these commands during low-traffic periods (like late at night) to minimize impact on your store's users.
2. Automated Scheduled Backups (Perfect for Daily Tasks)
If you need daily backups without manual intervention, Magento 2's built-in scheduled backup feature is ideal—and it doesn't require maintenance mode either. Here's how to set it up:
- Log into your Magento 2 admin panel.
- Navigate to Stores > Settings > Configuration.
- Expand the Advanced > System section.
- Scroll down to the Backup Settings group:
- Set Enable Scheduled Backup to Yes.
- Choose your desired Backup Type (database, code, media, or full backup).
- Set the Start Time to a low-traffic window (e.g., 2:00 AM).
- Set Frequency to Daily.
- Confirm the Backup Directory (default is
var/backups—ensure this directory has proper write permissions).
Once configured, Magento will automatically run the backup at your specified time, no maintenance mode needed.
Key Considerations
- Performance Impact: Backups consume server resources, especially full backups. Always schedule or run them during off-peak hours to avoid slowing down your store for customers.
- Backup Validation: Don't skip verifying your backups! Periodically test restoring a backup to ensure it's complete and functional—this prevents surprises if you ever need to recover your store.
- Storage Management: Backup files can take up significant disk space. Set up a routine to delete old backups, or sync them to an external storage service for added security.
- Permissions: Make sure the user running the backup commands (or the Magento cron user for scheduled backups) has read/write access to the
var/backupsdirectory and all Magento files.
内容的提问来源于stack exchange,提问作者Faisal I

