What command should I use to backup and restore the Magento 2 easily
Backup
Here is the command usage to backup the Magento 2
magento setup:backup [--code] [--media] [--db]
[–code] is backing up the Magento file system (excluding var and pub/static directories).
[–media] is backing up the pub/media directory.
[–db] is backing up the Magento 2 database.
if you would like to backup database and Magento file system, you should execute the following command
magento setup:backup --code --db
Restore
When you try to restore the backup, first you need to get backup name.
Run the following command to get backup name.
magento info:backups:list
Once you got the backup name, execute the following command
magento setup:rollback -m 1440512939_filesystem_media.tgz