Data directory docker-compose

Hi,

I want to backup my nextcloud-data to Storj via Duplicati. How can I get my data-directory into my home directory (home/myname/Documents/nextcloud/) instead of in /var/lib… I’m using docker-compose. See config below. Thanks in advance for your help.

version: ‘2’

volumes:
nextcloud:
db:

services:
db:
image: mariadb
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=passwd
- MYSQL_PASSWORD=passwd
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=user

app:
image: nextcloud
restart: always
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/home/user/nextcloud/data
environment:
- MYSQL_PASSWORD=passwd
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=user
- MYSQL_HOST=db

Try mounting your host folder to the container as a volume:

app:
  volumes:
    - '/home/myname/Documents/nextcloud:/var/lib/..."

That would probably work fine on a new installation, but I’m not sure it would copy the files if you make that change on an existing container. He might just end up with an empty data folder.

Would a symlink be sufficient? Keep in mind you MUST NOT change the file permissions or ownership, in either case.

1 Like

Thanks, but… That helped (a little). Data-files (and all other) are now inside home-dir. But I can’t make a backup because the access to the data-directory is denied. My login-user is not aan super-user. I guess it is not wise to chown / chmod?

Found a solution that works for me. Now running Duplicati (via docker-compose) with PUID=0 and PGID=0. All “local” behind a tailscale mesh VPN.