A couple simple questions about the usage of the Nextcloud Data Directory

Sorry to hear you’re facing problems. :slightly_frowning_face:

There is no problem, yet. This is not a support questions. But your unfriendly, user-hostile system, says that it is a support question. So I’m posting here.

The Basics

  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • AIO – The only relevant factor here.

Web Browser

  • n/a – any browser anywhere anytime

Questions

If I have the NEXTCLOUD_DATADIR variable set it appears that at least some of my data is available and saved on a local directory.

(1) If I then want to reset all my containers and images, and volumes, (but not the data dir volume), will Nextcloud be able to see and use the existing data on start-up? That is, can I rebuild (perhaps as part of an upgrade) my AIO Nextcloud, but keep my password, images, calendar, etc. without having to reset from scratch?

(2) Also, is backing up the contents of the nextcloud_datadir equivalent to making a backup of the essential parts of Nextcloud? That is, can a backup of the datadir be used as a replacement for the internal Borg backup (which I don’t entirely trust).

Thanks!

Hi,

There are two different cases here, and they should not be mixed.

If you only remove/recreate containers and images, but keep the AIO Docker volumes and the configured NEXTCLOUD_DATADIR, then the instance can normally continue using the existing state. Containers are disposable; the persistent state is in the volumes/datadir.

However, if you remove the AIO volumes as well and only keep NEXTCLOUD_DATADIR, that is not a full restore of the instance.

The datadir contains the file data and some app-related data, but it is not the whole Nextcloud instance. Important parts such as the PostgreSQL database, users, passwords, shares, calendars, contacts, app configuration, file metadata, and AIO configuration live outside the datadir.

One important AIO-specific detail: if you recreate or restart the AIO mastercontainer via Docker Compose after the initial installation, make sure the existing AIO mastercontainer volume is reused correctly.

For example, the AIO mastercontainer volume should be declared with the exact name and marked as external after it has already been created:

volumes:
  nextcloud_aio_mastercontainer:
    name: nextcloud_aio_mastercontainer
    external: true

This matters because nextcloud_aio_mastercontainer stores the AIO configuration/state used by the mastercontainer. Marking it as external tells Docker Compose that this is an existing persistent volume which must be reused, not treated as a new project-managed volume. It also helps avoid accidentally removing or replacing it when recreating the stack.

More here - Proxmox + NGINX + Nextcloud AIO + Watchtower Deployment Guide

So for your questions:

  1. Keeping only NEXTCLOUD_DATADIR is not enough to rebuild the same AIO instance with users, passwords, calendars, shares, etc. intact. At best, you may still have the raw files, but not a consistent restored Nextcloud instance.

  2. No, backing up only the datadir is not equivalent to an AIO/Borg backup. A complete backup needs at least the database, the relevant AIO Docker volumes/configuration, and the datadir, taken in a consistent state.

If you do not want to rely only on the built-in Borg backup, I would not replace it with a datadir-only backup. A safer approach is to keep the AIO Borg backup and additionally have an independent backup/snapshot strategy for the whole AIO state: all relevant Docker volumes plus the external datadir, with the containers stopped properly before the backup.

In short: datadir backup is useful, but it is not a complete Nextcloud backup. And when recreating AIO with Docker Compose, make sure the existing nextcloud_aio_mastercontainer volume is reused, typically with external: true after the first setup.

Thank you for your response.

If the NEXTCLOUD_DATADIR doesn’t have all the data, I guess I misunderstood its purpose. What is the utility of the nextcloud data directory?

Thanks!

The main utility of NEXTCLOUD_DATADIR is simple: it lets you choose where Nextcloud stores the actual user files on disk.

For example, instead of keeping the files wherever Docker would normally store them, you can place them on a larger disk, separate storage mount, ZFS dataset, RAID array, etc.

So it is mainly about storage location and storage management.

A simple library analogy:

  • NEXTCLOUD_DATADIR is where the books are physically stored on the shelves

  • the database and configuration are the library catalogue, user accounts, permissions, sharing information, calendars, contacts, and the information that tells Nextcloud how everything belongs together

The important point is that this catalogue is not stored inside NEXTCLOUD_DATADIR. In AIO, the database, configuration, and other instance state are stored separately from the datadir, in the relevant Docker/AIO volumes.

So yes, the datadir is very important. Without it, your user files are gone.

But by itself it is not enough to recreate the whole Nextcloud instance. It stores the files, but not the complete Nextcloud state.

For a proper restore you still need the datadir together with the database, configuration, and the relevant AIO Docker volumes.