Project

General

Profile

Moving Nextcloud to a New Server » History » Version 8

Gareth Eaton, 10/06/2024 07:42 PM

1 1 Gareth Eaton
h1. Moving Nextcloud to a New Server
2
3 3 Gareth Eaton
Step 1: Backup the Old Nextcloud Data Folder
4 1 Gareth Eaton
5 3 Gareth Eaton
1.1. Use FileBrowser to access your server. If you don't have FileBrowser installed, you can get it using the following commands:
6
7 1 Gareth Eaton
<pre>
8
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
9
</pre>
10 3 Gareth Eaton
11
1.2. Login to FileBrowser using this command:
12
13 1 Gareth Eaton
<pre>
14
filebrowser -a 192.168.*.* -p 8080
15
</pre>
16
17 3 Gareth Eaton
Replace 192.168.*.* with your server's IP address. Access FileBrowser via your web browser at http://192.168.*.*:8080.
18 1 Gareth Eaton
19 3 Gareth Eaton
1.3. Download the Nextcloud Data folder.
20 1 Gareth Eaton
21 3 Gareth Eaton
Step 2: Backup Your MySQL Database
22
23
Back up your MySQL database using this command:
24
25 1 Gareth Eaton
<pre>
26 8 Gareth Eaton
mysqldump -u your_mysql_username -p your_database_name < your_backup_file.sql
27 3 Gareth Eaton
</pre>
28
29
In my case, it might look like this:
30
31
<pre>
32 8 Gareth Eaton
mysqldump -u nextcloud -p nextcloud > nextcloud-sqlbkp.bak
33 1 Gareth Eaton
</pre>
34
35 3 Gareth Eaton
Step 3: Install a New Copy of Ubuntu and Nextcloud
36 1 Gareth Eaton
37 3 Gareth Eaton
3.1. Install a new copy of Ubuntu 20.04 on your new server. Update the system and follow the instructions to install Nextcloud.
38 1 Gareth Eaton
39 3 Gareth Eaton
3.2. During the Nextcloud installation, create a user named "nextcloud-admin."
40 1 Gareth Eaton
41 3 Gareth Eaton
3.3. Put Nextcloud into maintenance mode using this command:
42 1 Gareth Eaton
<pre>
43 6 Gareth Eaton
sudo -u www-data php /var/www/html/nextcloud/occ maintenance:mode --on
44 1 Gareth Eaton
</pre>
45
46 3 Gareth Eaton
Step 4: Upload Database and Data Folder
47
48
4.1. Using FileZilla, upload the database and data folder to the new server.
49
50
Step 5: Move Data to the Nextcloud/Data Folder
51
52
Use rsync to move the data to the Nextcloud data folder:
53
54
55 1 Gareth Eaton
<pre>
56
sudo rsync -avP source_directory/ /var/www/html/nextcloud/data/
57 5 Gareth Eaton
58
sudo chown -R www-data:www-data /var/www/html/nextcloud
59
sudo chmod -R 775 /var/www/html/nextcloud
60 1 Gareth Eaton
</pre>
61
62 3 Gareth Eaton
Step 6: Restore the Database
63 1 Gareth Eaton
64 3 Gareth Eaton
Restore the database using this command:
65
66 1 Gareth Eaton
<pre>
67 3 Gareth Eaton
mysql -u your_mysql_username -p your_database_name < your_backup_file.sql
68
</pre>
69
70
For example:
71
72 4 Gareth Eaton
<pre>
73
mysql -u nextcloud -p nextcloud < nextcloud-sqlbkp.bak
74 5 Gareth Eaton
</pre>
75 1 Gareth Eaton
76 5 Gareth Eaton
77
Take it out of maintenance mode by running the following command:
78
79 1 Gareth Eaton
<pre>
80 7 Gareth Eaton
sudo -u www-data php /var/www/html/nextcloud/occ maintenance:mode --off
81 2 Gareth Eaton
</pre>
82 3 Gareth Eaton
83 2 Gareth Eaton
Step 7: Verify Access and Data
84 1 Gareth Eaton
85
You should now be able to access your Nextcloud. Verify that your users and files are intact.
86 5 Gareth Eaton
87
Go to the Administration Setting and fix an problems that are showing up.