here is a simple command used to create backup :
Below cmd creates full system backup containing Magento 2 file system, the media directory, and the database; you can see the corresponding flags –code, –media, –db I used.
php bin/magento setup:backup --code --media --db
It automatically enables maintenance flag and disable once completed.
Happy coding 🙂