Backing up data with AIO container

Nextcloud version (eg, 29.0.5): 30.0.1
Operating system and version (eg, Ubuntu 24.04): Alpine Linux 3.20.3
Apache or nginx version (eg, Apache 2.4.25): nginx/1.26.2
PHP version (eg, 8.3): 8.2.24

Hi there, I was reading this page on backing up your Nextcloud instance: Backup — Nextcloud latest Administration Manual latest documentation

I installed Nextcloud with Docker and the AIO container, using this command:

docker run \
--init \
--sig-proxy=false \
--name nextcloud-aio-mastercontainer \
--restart always \
--publish 8080:8080 \
--env APACHE_PORT=11000 \
--env APACHE_IP_BINDING=0.0.0.0 \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
nextcloud/all-in-one:latest

My question is, how do the commands for backup in the Nextcloud docs change given that I’m running Nextcloud in a container? e.g. for

rsync -Aavx nextcloud/ nextcloud-dirbkp_`date +"%Y%m%d"`/

what do I replace nextcloud/ with? I’m not sure where the relevant directory would be on my system.

I would like to back up all data, including user data and configs, so that if something happened to my server I could recreate my entire Nextcloud instance with a backup.

Sorry if this is too basic of a question, I tried to do some searching around but still don’t know the answer to this question.

Hi, see GitHub - nextcloud/all-in-one: 📦 The official Nextcloud installation method. Provides easy deployment and maintenance with most features included in this one Nextcloud instance.

1 Like

If we’re talking about Nextcloud AIO, I recently migrated AIO to another server using RSYNC, so I have recent experience with it. I’ve written a guide on how to do it as efficiently as possible, and part of it includes a detailed description of how to handle it. I can imagine that the part about backing up AIO Docker containers might be helpful to you.

Unfortunately, I’m unavailable today, but I could put it together for you this evening or tomorrow if you’re interested. I just need to translate it from my native language, which is not English.

Thank you! Don’t know how I missed that :sweat_smile:

This would also be a helpful resource to have on hand, I’m new to my hosting provider so I don’t know if I want to stick with them long-term.

This guide covers the backup of Docker volumes using rsync from a server to a local disk while preserving synchronization parameters, followed by synchronization from the local storage to a new server, which can be considered equivalent to a backup process.

The process is divided into two steps:

Important: The local disk used for backup must have a Linux filesystem.
NTFS cannot retain information about the owners and groups of individual folders and files, which is crucial for Docker volumes, including Nextcloud AIO.
Additionally, Linux filesystems, such as ext4, may encounter issues with synchronizing larger files (e.g., multimedia files) in Nextcloud AIO.
Therefore, it is recommended to use another filesystem, such as xfs.

1. Backup of Docker Volumes (Server → Local Storage)

Preparing the Directory on the Local Disk

First, create the target directory where the Docker volumes will be backed up:

sudo mkdir -p /mnt/xfs4tera/tony/backup/docker-folders

Synchronizing Docker Volumes

Use the following rsync command to back up the volumes from the original server to the local disk. The command preserves permissions, ownership, and extended attributes, while also excluding certain files:

sudo rsync -ahPz -o -g -A -X --numeric-ids --bwlimit=97280 root@192.168.1.139:/var/lib/docker/volumes/ /mnt/xfs4tera/tony/backup/docker-folders/
  • --bwlimit=97280 limits the synchronization speed to 95 MB/s. This parameter is optional and was used because the transfer from the original server was failing without this limitation.

2. Synchronization to the New Server (Local Storage → New Server)

After backing up the Docker volumes to the local disk, these data need to be synchronized to the new server.

Synchronization Command

Use the following rsync command to synchronize from the local storage to the new server:

sudo rsync -ahPz -o -g -A -X --numeric-ids --exclude='backingFsBlockDev' --exclude='metadata.db' /mnt/xfs4tera/tony/backup/docker-folders/ root@192.168.1.139:/var/lib/docker/volumes/
  • --exclude='backingFsBlockDev' and --exclude='metadata.db' ensure that these files are not synchronized, as they should already exist on the new server.

Note:
Tested Environment: This guide has been tested on Ubuntu Server 24.04 with the xfs filesystem.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.