Cannot backup/restore NCP when runnning in Docker container


I’m running NCP in a docker container on the Debian OS running in SD card, NC data is in a persistant volume on the external drive.

The NCP and Nextcloud are running really well BUT I haven’t succeed to backup and restore the Nextcloud instance.

Is there a step-by-step guide on how to backup and recover NC instance (without data) and NCP-config when we run NCP in docker container?

My not successful setup and BACKUP/RESTORE steps are:

  1. To start NCP, I use this docker command:
    docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /srv/dev-disk-by-label-XXXX/appdata/ncdata:/data --restart unless-stopped --name nextcloudpi ownyourbits/nextcloudpi-arm64

2. In the container: backup NC and NCP (via NCP Web GUI or via CLI in the container):
nc-backup backup.tar
nc-export-ncp backup-ncp.cfg

  1. In the host OS: backup the persistant volume with
    cp -r /srv/dev-disk-by-label-XXXX/appdata/ncdata /PATH_TO_BACKUP/ncdata

To Stop and remove NCP container:
4. In the host machine: Stop and remove running container (via Portainer or CLI in the host OS):
docker stop nextcloudpi
docker rm nextcloudpi

5. Start new container with a new persistant dir (with backup data) and a new container name:
docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /srv/dev-disk-by-label-XXXX/appdata/ncdata-new:/data --restart unless-stopped --name nextcloudpi-new ownyourbits/nextcloudpi-arm64

  1. Restore NC instance and NCP config
    nc-restore /PATH_TO_BACKUP/ncdata/backups/backup-ncp/backup.tar
    nc-import-ncp /PATH_TO_BACKUP/ncdata/backups/backup-ncp/backup-ncp.cfg

This new instance is not working properly. A bunch of errors that are not always the same when I try this procedure several times.

Are these steps correct? Or is there something I am missing because of Docker container retaining some cache somewhere?

Instead of

maybe try with

rsync -a /srv/…

It will include hidden files

Containers are transient in their nature, there is no need to backup and restore anything inside of the container - once you start new container using exactly the same command (or docker-compose) you will receive a fresh container doing exactly same thing the old one did… this is the reason you put everything you need to persist on persistent volumes and change nothing inside of the container (one hint - don’t use :latest tag but always use defined version to have this predictable and reproducible container experience)

Following OliverV recommendation to use rsync -a /srv/… to backup the persistent volume. And assuming as wwe stated that NCP docker starting fresh with same command is exactly the same as the previous container, I run the following simpler backup test:

  1. Stop docker container.
  2. Rsync -a the persistent volume to another location
  3. Start docker container with same command except that the data is in another location.

I get the error below:

/ line 47: /etc/services-enabled.d//etc/services-enabled.d: No such file or directory

1 Like

H again,

I solved my problem of backup using Docker container NCP:

By restoring the persistent volume to exactly the same folder, the new container works perfectly well.

The problem was that my backup persistent volume had a different path AND the database needs the paths to be the same.

I did not find a way to migrate NCP installation to run a new docker container with the data backed up in a persistent volume with different path.
if anyone knows how to do such migration, I would like to try it out.

thanks for the previous replies pointing me in the right direction.

1 Like