Also, we need to export the MySQL backup file. There are two possible ways of dumping the database.
In case the database is deployed on the same server, execute:
sudo mysqldump --lock-tables -u root -p nextcloud_db > [preferred location]/nextcloud-dirbkp_`date +"%Y%m%d"`/
Where [preferred location] is a destination of the exported folder.
If the database is deployed on a different server, run the following command:
mysqldump --single-transaction -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak