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

WARNING
This command deletes the specified files or the database before restoring them. For example, the --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.
NOTE
To display a list of available backup files, enter magento info:backups:list

This command performs the following tasks:

  1. Puts the store in maintenance mode.

  2. Verifies the backup file name.

  3. If you specify a code rollback file:

    a. Verifies that the rollback destination locations are writable (note that the pub/static and var folders are ignored).

    b. Deletes all files and directories under your application installation directory.

    c. Extracts the archive file to the destination locations.

  4. If you specify a database rollback file:

    a. Drops the entire database.

    b. Restores the database using the database backup.

  5. 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.

  6. 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
    
NOTE
To run the magento command again without changing directories, you might need to enter cd pwd.
Previous pageUninstall language packages
Next pageUninstall or reinstall Commerce