Files alone are not a backup. The database, the config and one small secret decide whether a restore actually works.
Ask most self-hosted cloud owners what their backup is and they point at the data folder. That folder without its database is an unnamed pile of files. This page gives the complete four-part backup for a Nextcloud plus OnlyOffice system - including the small OnlyOffice settings everyone forgets until restore day.
Copying the Nextcloud data folder feels like a backup and is only half of one. The database holds the users, groups, shares, file versions, trash state and the map between files and their owners. Restore files without the database and Nextcloud sees a hard drive of orphaned data it cannot attach to anyone. The complete unit is always: data folder + database dump + config, taken at the same quiet moment.
Put Nextcloud into maintenance mode for the copy so the database and files match: sudo -u www-data php occ maintenance:mode --on, take the backup, then sudo -u www-data php occ maintenance:mode --off. (Adjust the user and path to your install.)
mysqldump --single-transaction -u nextcloud -p nextcloud > nextcloud-db.sql - again, match the names to your install.pg_dump -U nextcloud nextcloud > nextcloud-db.sql.config/config.php with it - it holds the database password, the instance secrets and your trusted domains. Losing it makes the dump much harder to use.The good news: documents live in Nextcloud, so the Docs server holds almost no unique data. The bad news: it holds the settings that make the pairing work - its configuration (local.json or the container definition) and above all the JWT secret. Record them in the backup notes. A rebuilt Docs server with a fresh secret will refuse every document until the connector in Nextcloud is updated with the same new value - plan that step into the restore instead of discovering it during one.
One timing warning: the Docs server keeps live editing sessions in its cache. Back up during quiet hours, because a session in progress during a server loss can lose its last unsaved moments no matter how good the file backup is.
A backup on the same disk protects against exactly nothing that matters - not disk death, not ransomware, not a stolen server. Keep at least one copy on a different machine or an external drive that is not permanently mounted. And do the unfashionable step: once, restore the whole thing onto a spare machine or VM and open a document through the editor. A backup that has never been restored is a hope, not a backup.
Once the video's setup is running, this page is your next job - before the team puts a single real file in.
Watch Full VideoYou can, and for large systems people snapshot instead - but a live copy risks the database and files being from slightly different moments, which shows up as missing files or broken shares after restore. For a small office, ten quiet minutes in maintenance mode is the cheap, correct route.
Almost no data - documents live in Nextcloud. What you need is its configuration and the JWT secret, so the rebuilt Docs server pairs with Nextcloud exactly as before. Record both in your backup notes, outside the server.
Match it to how painful one lost day would be. Most small offices run a nightly backup of database and config, with the data folder synced or snapshotted on the same rhythm, and keep several generations - one corrupt day should not overwrite the only good copy.