How to backup and restore with Magento 2

Magento 2 comes with built-in functionality to backup and restore the code, media, and database. You can choose to backup and restore code, media, or database separately. Here’s how to backup and restore with Magento 2.

Backup

Change directory to your Magento 2 install and run the following command:

This will enable maintenance mode and perform the backup. Note that the live site will not be available when this is happening.

Output from a backup is similar to the below:

Restore

Restoring backups is as easy as creating them. First list the available backups:

This will list the three backups:

You can then restore these using the following syntax:

Again, this will enable maintenance mode and perform the restore. Note that the live site will not be available when this is happening.