You can find more information in documentation here - https://docs.nextcloud.com/server/12/admin_manual/maintenance/backup.html
Below is set of commands which works on Turris Omnia
# enable maintenance mode sudo -u nobody php-cli /srv/www/nextcloud/occ maintenance:mode --on # backup files rsync -ax /srv/www/nextcloud /srv/www/nextcloud-dirbkp_`date +"%Y%m%d"`/ # backup database mysqldump --single-transaction -h localhost -u root nextcloud > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak # disable maintenance mode sudo -u nobody php-cli /srv/www/nextcloud/occ maintenance:mode --off