Hi all,
I have a raspberry pi with the NCP image for myself and 6 other users, all data is stored on a external usb disk (BTRFS) /media/drive/ncdata. Now I would like to migrate to nextcloudpi docker on a new server with ubuntu server and docker. I think I got it work, see below the steps I have executed so far.
First try:
- I ran nc-export with all data
- started the docker container (with volume /media/ncdata, EXT4)
- I ran nc-restore on the docker but got an error about BTRFS
- I ran nc-export without all data
- I added a new partition with filesystem BTRFS and mounted the partition on /media/ncdata
- I ran nc-restore and got errors about missing data directories
- Tried all kinds of different things like changing datadirectory in config.php file but it did not work
Second try:
-
preserve database and nextcloud folder on pi:
rsync -Aavx /var/www/nextcloud/ /media/drive/backup/nextcloud-dirbkp/
mysqldump --single-transaction -u ncadmin nextcloud > nextcloud-sqlbkp_date +"%Y%m%d"
.bak -
transfer files from pit to new server
sudo /usr/bin/rsync -aAx -e --delete “/media/drive/backup/” “user@IP:location/” -
transfer data from myself to new server
-
file permissions changed during transfer so I executed a chown www-data:www-data *
-
on server maintenance mode on:
docker exec -it nextcloudpi sudo -u www-data php /data/nextcloud/occ maintenance:mode --on -
drop and create database
docker exec -it nextcloudpi sudo mysql -u ncadmin -e “DROP DATABASE nextcloud”
docker exec -it nextcloudpi sudo mysql -u ncadmin -e “CREATE DATABASE nextcloud” -
import database (argument -t gave some TTY error)
sudo docker exec -i nextcloudpi sudo mysql -u ncadmin nextcloud < nextcloud-sqlbkp_20200417.bak -
moved nextcloud folder in place
rsync -Aax nextcloud-dirbkp/ /media/ncdata/nextcloud/ -
in config file I change datadirectory and trusted domains
-
I moved all data into the new datadirectory
-
restart apache
docker exec -it nextcloudpi service apache2 reload -
turn maintenance mode off
docker exec -it nextcloudpi sudo -u www-data php /data/nextcloud/occ maintenance:mode –off
Now I received an error:
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user ‘ncadmin’@‘localhost’ (using password: YES) in /data/nextcloud/lib/private/DB/Connection.php:68
- Stop and start the container and try again
Another error
An unhandled exception has been thrown:
RuntimeException: Could not get appdata folder in /data/nextcloud/lib/private/Files/AppData/AppData.php:95
-
Another restart of apache
docker exec -it nextcloudpi service apache2 reload -
And finally I was able to turn the maintenance mode off
docker exec -it nextcloudpi sudo -u www-data php /data/nextcloud/occ maintenance:mode –off -
still to do: migrate all data to new server
My questions:
- Did I miss something somewhere?
- Do I still need the BTRFS filesystem with the second method?
- Why did the first attempt fail? Is it even possible what I was trying to do?
- What should be the steps after step 10 in the second attempt, I have no idea why I got these errors.
- and what would be the best backup strategy from now on?
Thanks in advance!