Moving Nextcloud to a New Server » History » Revision 5
Revision 4 (Gareth Eaton, 10/16/2023 12:59 AM) → Revision 5/8 (Gareth Eaton, 10/16/2023 01:01 AM)
h1. Moving Nextcloud to a New Server Step 1: Backup the Old Nextcloud Data Folder 1.1. Use FileBrowser to access your server. If you don't have FileBrowser installed, you can get it using the following commands: <pre> curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash </pre> 1.2. Login to FileBrowser using this command: <pre> filebrowser -a 192.168.*.* -p 8080 </pre> Replace 192.168.*.* with your server's IP address. Access FileBrowser via your web browser at http://192.168.*.*:8080. 1.3. Download the Nextcloud Data folder. Step 2: Backup Your MySQL Database Back up your MySQL database using this command: <pre> mysql -u your_mysql_username -p your_database_name < your_backup_file.sql </pre> In my case, it might look like this: <pre> mysql -u nextcloud -p nextcloud < nextcloud-sqlbkp.bak </pre> Step 3: Install a New Copy of Ubuntu and Nextcloud 3.1. Install a new copy of Ubuntu 20.04 on your new server. Update the system and follow the instructions to install Nextcloud. 3.2. During the Nextcloud installation, create a user named "nextcloud-admin." 3.3. Put Nextcloud into maintenance mode using this command: <pre> sudo -u www-data php occ maintenance:mode --on </pre> Step 4: Upload Database and Data Folder 4.1. Using FileZilla, upload the database and data folder to the new server. Step 5: Move Data to the Nextcloud/Data Folder Use rsync to move the data to the Nextcloud data folder: <pre> sudo rsync -avP source_directory/ /var/www/html/nextcloud/data/ sudo chown -R www-data:www-data /var/www/html/nextcloud sudo chmod -R 775 /var/www/html/nextcloud </pre> Step 6: Restore the Database Restore the database using this command: <pre> mysql -u your_mysql_username -p your_database_name < your_backup_file.sql </pre> For example: <pre> mysql -u nextcloud -p nextcloud < nextcloud-sqlbkp.bak </pre> Take it out of maintenance mode by running the following command: <pre> sudo chown -R www-data:www-data /var/www/html/nextcloud sudo -u www-data php occ maintenance:mode --off chmod -R 775 /var/www/html/nextcloud </pre> Step 7: Verify Access and Data You should now be able to access your Nextcloud. Verify that your users and files are intact. Go to the Administration Setting and fix an problems that are showing up.