Project

General

Profile

Moving Nextcloud to a New Server » History » Version 3

Gareth Eaton, 10/16/2023 12:57 AM

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 3 Gareth Eaton
mysql -u your_mysql_username -p your_database_name < your_backup_file.sql
27
</pre>
28
29
In my case, it might look like this:
30
31
<pre>
32 1 Gareth Eaton
mysql -u nextcloud -p nextcloud < nextcloud-sqlbkp.bak
33
</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
sudo -u www-data php occ maintenance:mode --on
44
</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
</pre>
58
59 3 Gareth Eaton
Step 6: Restore the Database
60 1 Gareth Eaton
61 3 Gareth Eaton
Restore the database using this command:
62
63 1 Gareth Eaton
<pre>
64 3 Gareth Eaton
mysql -u your_mysql_username -p your_database_name < your_backup_file.sql
65
</pre>
66
67
For example:
68
69
<pre>
70 1 Gareth Eaton
mysql -u nextcloud -p nextcloud < nextcloud-sqlbkp.bak
71
</pre>
72 2 Gareth Eaton
73 3 Gareth Eaton
Step 7: Verify Access and Data
74 2 Gareth Eaton
75 3 Gareth Eaton
You should now be able to access your Nextcloud. Verify that your users and files are intact.