Hello,
I am trying to setup backup processes for our docker nextcloud installation and also practicing restore routines, but having some questions and issues.
What would be the correct way to backup Docker-style NC installation?
I know I could simply stop containers and then backup entire volumes to external storage, but I would prefer backing up only what is needed to be able to follow more of a “provision” style backup and restore. At the moment I follow these steps:
- Copy
config.php
only to backup location. - Make a backup of SQL database and store that in backup location.
- User data is going to be stored in a separate partition together with external data sources. These folders will be backed up as is.
Currently I try to restore as follows (it is more of a clean install):
- Completely remove all containers.
- Wipe all current data in container volumes, i.e.
/var/www/html
including configs etc. Wipe and SQL volume data. - Recreate SQL container, wait until db is initialized, and restore saved SQL
*.bak
backup. - Start Nextcloud container (with admin user defined in
env
variables).
However, at the moment, I face following issues with this way:
- I am not able to create NC container with the same admin user as it was before since it complains that files/folder for that user is already created. I get away with this by using temporary admin user for installation and then deleting it later. Is there a better way solving this issue?
- NC cannot proceed with the installation when container starts up because it complains that
maintenance:install
method is not present. I found out that I had to change line inconfig.php
file'installed' => 'true'
tofalse
and creating blank file calledCAN_INSTALL
in config directory . This works and launches installation. Are these steps sufficient to invoke correct installation process? - I still do not understand what additional steps should be done as I am not really sure what stays in that database. Do I have to install apps manually via
occ
in my case? Where are app installations stored? I noticed that they seem to be not restored with the SQL database. However data of some apps (like Deck) seem to be saved in SQL (I later installed app manually and decks/cards were displayed for users). - If I have to install apps manually, how to know if NC installation has been finished? I found it difficult to find decent flag that indicates that NC installation in container is completed. Since
Config.php
lineinstalled
is changed right after installation starts, it cannot be used for this purpose. - Does this approach seem viable? I really wish to have setup that would less prone to issues and would allow me to proceed with NC updates easier.
My docker compose file looks like this:
version: '3.8'
services:
db:
image: mariadb:10.11
container_name: mariadb
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- ./mariadb/sql:/var/lib/mysql
env_file:
- ./mariadb/env-files/sql.env
healthcheck:
test:
[
"CMD",
"/var/lib/mysql/sql_health.sh",
"--su-mysql",
"--connect",
"--innodb_initialized"
]
start_period: 5s
interval: 5s
timeout: 3s
retries: 3
networks:
- nc-net
redis:
container_name: redis
image: redis:alpine
restart: always
networks:
- nc-net
app:
image: nextcloud:stable-apache
container_name: nextcloud
restart: always
ports:
- 8080:80
depends_on:
- redis
- db
volumes:
- ./nextcloud/core-data:/var/www/html
- ./nextcloud/config:/var/www/html/config
- /home/nas/data/external:/var/www/data
- /home/nas/data/user:/var/www/html/data
env_file:
- ./nextcloud/env-files/nc.env
networks:
- nc-net
networks:
nc-net:
name: nc-net
driver: bridge
Thank you very much.