Restore a nextcloud AIO instance from a broken state

I feel kinda stupid about this problem, I am quite the newbie when it comes to docker, but here is the situation:

I am running ubuntu server 22.04 and the docker snap. I wanted to have the nextlcoud save-data on a separate harddrive on my server, and because there seemed to be no real elegant way to go about this when using the nextcloud docker-aio setup, I just bind-mounted the entire /var/snap/docker directory to a directory on my separate harddrive. This worked fine, until a few days ago I needed to restart the server, and suddenly all the containers didn’t show up anymore. I really cant explain how the nextcloud instance ran fine before the restart and suddenly everything was broken after the restart.
I have a (yes, very crude) backup of the entire /var/snap/docker/common/var-lib-docker directory though and thought that just replacing that should work. But it didn’t. The mastercontainer starts fine, but the apache and database-container seemed to complain about missing writing privileges. Output from the logs (both repeated multiple times):

DUMP dir is not writeable by postgres user.
Cannot write to /mnt/data

So that didn’t help me much. The next thing I thought was “all the persistent data in docker setups is stored in volumes, maybe just setting up a new aio instance and replacing the volumes will work”. Of course that also didn’t do it, now the database-container gives me this output (repeated multiple times):

Setting max connections...

PostgreSQL Database directory appears to contain a database; Skipping initialization

2023-01-22 22:28:17.517 UTC [12] LOG:  starting PostgreSQL 14.6 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit
2023-01-22 22:28:17.517 UTC [12] LOG:  listening on IPv4 address "", port 5432
2023-01-22 22:28:17.517 UTC [12] LOG:  listening on IPv6 address "::", port 5432
2023-01-22 22:28:17.528 UTC [12] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-01-22 22:28:17.540 UTC [20] LOG:  database system was interrupted; last known up at 2023-01-21 10:39:02 UTC
2023-01-22 22:28:17.682 UTC [20] LOG:  database system was not properly shut down; automatic recovery in progress
2023-01-22 22:28:17.688 UTC [20] LOG:  redo starts at 0/43F596F8
2023-01-22 22:28:17.689 UTC [20] FATAL:  could not open file "base/16384/16554_vm": Permission denied
2023-01-22 22:28:17.689 UTC [20] CONTEXT:  WAL redo at 0/43F5C328 for Heap/UPDATE: off 7 xmax 1426133 flags 0x01 ; new off 1 xmax 0; blkref #0: rel 1663/16384/16554, blk 0 FPW
2023-01-22 22:28:17.690 UTC [12] LOG:  startup process (PID 20) exited with exit code 1
2023-01-22 22:28:17.690 UTC [12] LOG:  aborting startup due to startup process failure
2023-01-22 22:28:17.692 UTC [12] LOG:  database system is shut down
touch: /mnt/data/export.failed: Permission denied
pg_dump: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?
pg_ctl: PID file "/var/lib/postgresql/data/" does not exist
Is server running?
Database dump unsuccessful!

In conclusion: I have an entire /var/snap/docker/common/var-lib-docker directory containing only a nextcloud aio instance that won’t start anymore and I want to restore the state of that instance is some way. Is that possible? Thanks in advance!

Hi, first of all: using the snap version of docker is disrecommended.

Second, you should have used this guide GitHub - nextcloud/all-in-one: Nextcloud AIO stands for Nextcloud All In One and provides easy deployment and maintenance with most features included in this one Nextcloud instance. to move the files to a separate drive.

Third, if you would have created a backup using the built-in backup solution, you could restore your whole instance on a new, clean AIO instance with just a few steps.

1 Like

All right, some of this I already realized and all of this I will consider in the future. But for now: Are you saying that somehow salvaging the nextcloud instance from what I have is impossible, or is it worth to keep trying and salvage the old state of my nextlcoud?
If I manage to do that I will definitely create a backup the proper way, set up a new instance properly and restore it from that backup.

You could try to fix the permission issue with sudo chmod -R 777 on each of the volumes that has problem but this is only a workaround to make it work again and not the recommended solution since the correct owners should be applied in best case but I dont have the time to help you figuring them out.

Edit: I posted the wrong command. Corrected.