nextcloud migration

Set system into maintenace mode

docker-compose exec --user www-data app php -d memory_limit=2048M occ maintenance:mode --on

Backup DB

docker exec db mysqldump --single-transaction -h localhost -u root -p[password] nextcloud > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

Sync folders

rsync -Aavx data -e ssh bodo@super71.home:/var/lib/docker/data/
rsync -Aavx custom_apps -e ssh bodo@super71.home:/var/lib/docker/data/
rsync -Aavx themes -e ssh bodo@super71.home:/var/lib/docker/data/
rsync -Aavx config -e ssh bodo@super71.home:/var/lib/docker/data/

Drop DB

docker exec mariadb mysql -h localhost -u root -p[password] -e "DROP DATABASE nextcloud"
docker exec mariadb mysql -h localhost -u root -p[password] -e "CREATE DATABASE nextcloud"

Restore DB

cat nextcloud-sqlbkp_20201110.bak | docker exec -i mariadb /usr/bin/mysql -u root --password=[password] nextcloud

Restore Files

rsync -Aax /var/lib/docker/data/data/ /var/lib/docker/volumes/docker_nextcloud-data/_data/
rsync -Aax /var/lib/docker/data/custom_apps/ /var/lib/docker/volumes/docker_nextcloud-custom_apps/_data/
rsync -Aax /var/lib/docker/data/themes/ /var/lib/docker/volumes/docker_nextcloud-config/_data/www/nextcloud/themes/

Set rights

docker-compose exec nextcloud chown -R 1002:1002 /config
docker-compose exec nextcloud chown -R 1002:1002 /data
docker-compose exec nextcloud chown -R 1002:1002 /config/www/nextcloud/custom_apps
docker-compose exec nextcloud updater.phar
docker-compose exec nextcloud occ maintenance:mode --on
docker-compose exec nextcloud find /data/ -type d -exec chmod 750 {} \;
docker-compose exec nextcloud find /data/ -type f -exec chmod 640 {} \;
docker-compose exec nextcloud occ files:scan --all
docker-compose exec nextcloud occ maintenance:repair