Roll back the file system, database, or media files
To restore the codebase to the state at which you backed it up, use the following command:
bin/magento setup:rollback [-c|--code-file="<filename>"] [-m|--media-file="<filename>"] [-d|--db-file="<filename>"]
Where <filename>
is the name of the backup file in the <app_root>/var/backups
directory. To display a list of backup files, enter magento info:backups:list
--media-file
option deletes media assets under the pub/media
directory before restoring from the specified rollback file. Make sure you have not changed the file system or database that you want to keep before using this command.magento info:backups:list
This command performs the following tasks:
-
Puts the store in maintenance mode.
-
Verifies the backup file name.
-
If you specify a code rollback file:
a. Verifies that the rollback destination locations are writable (note that the
pub/static
andvar
folders are ignored).b. Deletes all files and directories under your application installation directory.
c. Extracts the archive file to the destination locations.
-
If you specify a database rollback file:
a. Drops the entire database.
b. Restores the database using the database backup.
-
If you specify a media rollback file:
a. Verifies that the rollback destination locations are writable.
b. Deletes all files and directories under
pub/media
c. Extracts the archive file to the destination locations.
-
Takes the store out of maintenance mode.
For example, to restore a code (that is, file system) backup, enter the following commands in the order shown:
-
Display a list of backups:
magento info:backups:list
-
Restore a file backup named
1433876616_filesystem.tgz
:magento setup:rollback --code-file="1433876616_filesystem.tgz"
Messages similar to the following display:
Enabling maintenance mode Code rollback is starting ... Code rollback filename: 1433876616_filesystem.tgz Code rollback file path: /var/www/html/magento2/var/backups/1433876616_filesystem.tgz [SUCCESS]: Code rollback has completed successfully. Disabling maintenance mode
magento
command again without changing directories, you might need to enter cd pwd
.