Moving your Nextcloud server to a new one can be a daunting task, but with a clear guide, you'll be up and running in no time.
First, make sure you have a backup of your Nextcloud data, as outlined in the "Backing Up Nextcloud Data" section. This will ensure that your files and settings are safe in case something goes wrong during the transfer.
Before starting the migration, update your Nextcloud version to the latest one, as mentioned in the "Nextcloud Version Requirements" section. This will ensure that you have the latest features and security patches.
To begin the migration, follow the steps outlined in the "Preparing the New Server" section, which includes setting up the new server's operating system, web server, and database.
Preparing for Migration
Before you start migrating your Nextcloud instance to a new server, it's essential to prepare the new server. A prerequisite is a new VPS with more storage space and shell access, which we prepare for Nextcloud.
You'll need to install the necessary packages, including php7.2-fpm with Apache2 and mysql. To secure your mysql-installation, you'll need to add specific parameters. If php-APCu is in use, you'll also need to extend the php.ini file accordingly.
To synchronize data, you'll use rsync, so make sure it's installed on the destination server. Additionally, you'll need to adjust the /etc/sudoers file to use rsync with sudo.
Backing Up Data
Backing up your data is a crucial step in preparing for migration. Locate your data directory by opening the NextCloud config file.
Your data directory might not be in its default location, so you'll need to find it and use that path for backing it up. This path is usually located in the NextCloud config file, and it's essential to note the type of database your NextCloud uses.
To backup your data directory, run the command `tar -czf /var/lib/nextcloud/data.tar.gz /var/lib/nextcloud/data`, adjusting the path to your own data directory. Make sure to include the dot at the end of the command.
Verifying that the files have the correct dates is a good idea to ensure a successful backup.
Update DNS Entry
Updating your DNS entry is a crucial step in the migration process.
Once you've confirmed that NC is working properly, you can update the DNS entry to point to your new server. This will allow clients to access the new server once their DNS caches expire.
Don't forget to undo the change to server_name in the nginx config file, as mentioned in the setup process.
Server Migration
Server migration is a crucial step in preparing for a smooth transition. You should be aware that a downtime for your Nextcloud instance may arise, depending on the TTL in your DNS. It's recommended to reduce the TTL to the minimum and consider a first synchronization one day before the migration.
Before starting the migration, ensure you have a new VPS with more storage space and shell access. For Nextcloud 13 and php7.2-fpm with Apache2 and mysql, you can follow these steps: secure your mysql-installation by pasting specific parameters, and extend the php.ini if php-APCu is in use.
To synchronize your data, you'll use rsync. If it's not installed, install it on the destination server. Additionally, you'll need to adjust the /etc/sudoers on the destination server to use rsync with sudo.
Here's a step-by-step guide to the migration process:
1. Prepare the new server
- Secure mysql-installation
- Extend php.ini (if php-APCu is in use)
- Install rsync (if not already installed)
- Adjust /etc/sudoers
2. Synchronize certificates and Apache2 vhosts
- Synchronize certificates (adapt paths and new hostname/IP)
- Activate maintenance mode in Nextcloud
3. Migrate database
* Dump the Nextcloud database on the source server
4. Activate Apache2-vHosts and test
- Enable Nextcloud vHosts (http/https)
- Test the Nextcloud instance by entering the new IP address in your local hosts file
If you're using the ownCloud-to-Nextcloud migration tool, be aware that you may need to migrate from the latest version of ownCloud to Nextcloud Hub 3 (25) and then further upgrade Nextcloud. This is due to ownCloud not working with currently supported PHP releases (PHP8 or higher).
Server Configuration
You'll need to configure your new server to work with Nextcloud. A prerequisite is a new VPS with more storage space and shell access, which we prepare for Nextcloud. For Nextcloud 13 and php7.2-fpm with Apache2 and mysql, we can do the following things.
To secure our mysql-installation, we need to paste the following parameters. If php-APCu is in use, then the php.ini must be extended accordingly. To use rsync with sudo, we need to adjust the /etc/sudoers on the destination server.
We should also install rsync if it's not already installed. Live migration only: Before we begin, we should adapt the DNS record (A and possibly AAAA) to the new server IP.
To configure the Apache2-vHosts, we enable the two Nextcloud vHosts (http/https) with the following command. We can test the Nextcloud instance by entering the new IP address in our local hosts file on our workstation.
Here's a list of dependencies you may need to install on the new server:
- Missing dependencies of NC
- Update the NC config file with the new database user
To update the nginx config file on the new server, you'll need to update the server_name and other relevant settings. Activate nginx config on the new server with the following command. To test Nextcloud operation, point your browser to the server_name of the new Nextcloud instance.
Migration Process
Before we dive into the migration process, it's essential to prepare the new server for Nextcloud. This includes setting up a new VPS with more storage space and shell access.
To ensure a smooth migration, reduce the TTL in the DNS to minimize downtime. If possible, synchronize data one day before the migration. Testing the procedure beforehand is also crucial.
For the actual migration, you can use the Data Export/Import feature available since Nextcloud 24. This feature allows users to export their data in an archive, giving a choice of what to upload and when.
Cloudron Instance Migration Guide
Migrating your Cloudron instance can be a bit overwhelming, but don't worry, I've got you covered. You should be aware that depending on the TTL in the DNS, a downtime for your instance may arise. Reduce the TTL to the minimum if possible, and for larger amounts of data, you can do a first synchronization one day before.
A prerequisite for migration is a new server with more storage space and shell access, prepared for Cloudron. To synchronize, you'll use rsync later, so if it's not installed, install it on the destination server. You'll also need to adjust the /etc/sudoers file on the destination server to use rsync with sudo.
To start the migration process, adapt the DNS record (A and possibly AAAA) to the new server IP. Then, sync the certificates and Apache2 vHosts to the new server. You can do this by running the rsync command with the correct paths and hostname/IP.
Next, dump the Cloudron database with the mysqldump command, and copy it to the new server. Create a new database and user on the new server, and import the database dump. This will transfer all your data, including users, settings, and app configurations.
Here's a step-by-step guide to help you through the process:
- Create a database dump on the old server and copy it to the new server.
- Create a new database and user on the new server.
- Import the Cloudron database on the new server.
Note that some settings may not be transferred automatically, such as proprietary extensions from ownCloud that have open source replacements in Nextcloud. You may need to reconfigure these settings manually.
When migrating from ownCloud to Nextcloud, you can use the Data Export/Import feature, available since Nextcloud 24. This feature allows users to export their data in an archive, giving a choice of what to upload and when.
Mounting the Server
To mount CIFS shares, you need to have cifs-utils installed.
First, create a file to store the credentials to your backup server, so you don't have to use them as clear text in your script.
The cifs-utils package is a must-have for mounting CIFS shares.
You'll need to create a file to store your backup server credentials securely.
This file will hold the necessary information to connect to your backup server without exposing sensitive data.
Andreas Heik, TU Chemnitz
Andreas Heik, TU Chemnitz, was encouraged to migrate due to the recent development of Nextcloud, which offered a favorable licensing model and strong community support.
The licensing model of Nextcloud played a significant role in their decision to migrate, as it provided a more attractive option compared to other solutions.
The wide support of the community for Nextcloud also contributed to their confidence in making the switch, as it ensured they would have access to resources and expertise when needed.
Migration Tools and Guides
The migration process can be a bit daunting, but don't worry, we've got you covered. The easiest way to migrate is using the Nextcloud migration tool, which supports migrating to the appropriate Nextcloud release automatically.
If you're currently using ownCloud, you'll need to migrate from the latest version to Nextcloud Hub 3 (25) first, and then upgrade from there. This is because ownCloud doesn't work with any currently supported PHP release (PHP8 or higher). You can do the last step manually from the command line, which is advised on large installations where the time-out on PHP via the web interface can be a problem.
Nearly all ownCloud settings will be migrated to Nextcloud during the upgrade procedure. This means that internal and public shares will keep working, users will keep their settings, and you'll retain app configuration, LDAP, and external storage settings.
Here are some proprietary extensions from ownCloud that have open source replacements in Nextcloud and may need re-configuration:
- File Retention
- File Firewall
- File Automated Tagging
- File Drop
- SharePoint
These open source replacements in Nextcloud offer at least the same and typically more capabilities. Configuration settings not mentioned in this list will be carried over from ownCloud to Nextcloud during upgrade.
Sources
- https://markus-blog.de/index.php/2018/06/05/how-to-migrate-nextcloud-to-a-new-server-with-ubuntu-16-04-lts/
- https://www.ceos3c.com/linux/how-to-backup-nextcloud-and-move-them-to-another-server/
- https://nextcloud.com/migration/
- https://vdna.be/site/index.php/2019/03/migrating-nextcloud-to-a-new-server/
- https://forum.cloudron.io/topic/11614/guide-how-to-migrate-an-existing-nextcloud-instance-to-cloudron
Featured Images: pexels.com