Table of Contents generated with DocToc
Nextcloud
Migrating
Install dependencies:
sudo apt update
sudo apt dist-upgrade
sudo apt install apache2 mariadb-server libapache2-mod-php php-gd php-mysql php-curl php-mbstring php-intl php-gmp php-bcmath php-xml php-imagick php-zip php-apcu redis-server
Setup the database:
sudo mysql
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
quit;
On the original machine, put Nextcloud into maintenance mode.
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --on
WARNING Wait 6-7 minutes for the sync clients to register the server is in maintenance mode before proceeding.
Stop the web server that runs Nextcloud.
sudo systemctl stop apache2.service
Copy over the Nextcloud directory to the new machine:
rsync -aAX /var/www/nextcloud root@new-machine:/var/www
Copy the PHP configurations to the new machine:
rsync -aAX /etc/php/8.2/apache2/ root@new-machine:/etc/php/8.2/apache2
rsync -aAX /etc/php/8.2/cli/ root@new-machine:/etc/php/8.2/cli
WARNING The PHP version on the new machine must match that from the original machine.
On the new machine, ensure /etc/php/8.2/mods-available/apcu.ini
is configured correctly:
extension=apcu.so
apc.enable_cli=1
On the new machine, ensure permissions are set correctly on /var/www/nextcloud
:
sudo chown -R www-data:www-data /var/www/nextcloud
On the original machine, dump the database:
mysql --single-transaction --default-character-set=utf8mb4 -h localhost -u nextcloud -p nextcloud > nextcloud-sqlbkp.bak
Copy the database backup to the new machine:
rsync -aAX nextcloud-sqlbkp.bak root@new-machine:/root
On the new machine, import the database backup:
mysql -h localhost -u nextcloud -p -e "DROP DATABASE nextcloud"
mysql -h localhost -u nextcloud -p -e "CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"
mysql -h localhost -u nextcloud -p nextcloud < /root/nextcloud-sqlbkp.bak
On the new machine, ensure redis-server service is started:
sudo systemctl enable --now redis-server.service
On the new machine, run the following command to update the data-fingerprint
:
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:data-fingerprint
WARNING Ensure DNS records are changed to the new machine and the web server is running before taking Nextcloud out of maintenance mode.
On the new machine, take Nextcloud out of maintenance mode:
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --off