Backing up
Command usage:
bin/magento setup:backup [--code] [--media] [--db]
The command performs the following tasks:
-
Puts the store in maintenance mode.
-
Executes one of the following command options.
Option Meaning Backup file name and location --code
Backs up the file system (excluding var and pub/static directories). var/backups/<timestamp>/_filesystem.tgz
--media
Back up the pub/media directory. var/backups/<timestamp>/_filesystem_media.tgz
--db
Back up the database. var/backups/<timestamp>/_db.sql
-
Takes the store out of maintenance mode.
For example, to back up the file system and database,
bin/magento setup:backup --code --db
Messages similar to the following display:
Enabling maintenance mode
Code backup is starting...
Code backup filename: 1434133011_filesystem.tgz (The archive can be uncompressed with 7-Zip on Windows systems)
Code backup path: /var/www/html/magento2/var/backups/1434133011_filesystem.tgz
[SUCCESS]: Code backup completed successfully.
DB backup is starting...
DB backup filename: 1434133011_db.sql
DB backup path: /var/www/html/magento2/var/backups/1434133011_db.sql
[SUCCESS]: DB backup completed successfully.
Disabling maintenance mode
Rollback
This section discusses how to roll back to a backup you made previously. You must know the file name of the backup file to restore.
To find the name of your backups, enter:
bin/magento info:backups:list
The first string in the backup file name is the timestamp.
To roll back to a previous backup, enter:
bin/magento setup:rollback [-c|--code-file="<name>"] [-m|--media-file="<name>"] [-d|--db-file="<name>"]
For example, to restore a media backup named 1440611839_filesystem_media.tgz
, enter
bin/magento setup:rollback -m 1440611839_filesystem_media.tgz
Messages similar to the following display:
[SUCCESS]: Media rollback completed successfully.
Please set file permission of bin/magento to executable
Disabling maintenance mode
More help on this topic
Previous pageRemove or update modules
Next pageCheck the database status