I'd like to share my collection of scripts to back up, upgrade and restore Nextcloud Docker installations. They come handy especially if you are managing multiple Nextcloud installations on your server.
I am using the Docker Homelab for my Nextcloud instances.
NOTE: This scripts will only work if you...
- have installed your Nextcloud within a Docker container
- are using a container for the Nextcloud app and a separate container for the MySQL database
- are using a docker-compose file to bring up both containers
This scripts will only backup or restore the database and the config files of your Nextcloud installation!
pip3 install -r requirements.txt
- Copy the
example_config.yml
.
cp example_config.yml config.yml
- Adjust the
config.yml
with an editor of your choice.
The backup.py
script will create a backup of the database and the configuration of your Nextcloud installations.
You can adjust the backup directory and the maximum number of backups in the config.yml
.
python3 backup.py
or without user prompt
python3 backup.py cloud1 cloud2
The restor.py
script will restore the database and the configuration of your Nextcloud installations.
python3 restore.py
or without user prompt
python3 restore.py cloud1 cloud2
The upgrade.py
script will first back up and then try to upgrade your Nextcloud installations.
python3 upgrade.py
or without user prompt
python3 upgrade.py cloud1 cloud2
Flag | function |
---|---|
--yes | won't ask for confirmation |
--all | will treat all Nextcloud installations defined in the config.yml |
--quiet | the script will produce no output on terminal |
--nolog | no logs will be written |
--nocleanup | there will be no cleanup of the backup directory afterwards |
--nobackup | no backup will be made before upgrade |
- Sometimes the maintenance mode is not getting disabled properly after upgrades.
A simple
docker exec --user www-data <app-cotainer> php occ maintenance:mode --off
does the trick.