Moving Nextcloud to a New Server » History » Version 6
Gareth Eaton, 12/15/2023 02:55 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 | 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 | 6 | Gareth Eaton | sudo -u www-data php /var/www/html/nextcloud/occ maintenance:mode --on |
44 | |||
45 | 1 | Gareth Eaton | </pre> |
46 | |||
47 | 3 | Gareth Eaton | Step 4: Upload Database and Data Folder |
48 | |||
49 | 4.1. Using FileZilla, upload the database and data folder to the new server. |
||
50 | |||
51 | Step 5: Move Data to the Nextcloud/Data Folder |
||
52 | |||
53 | Use rsync to move the data to the Nextcloud data folder: |
||
54 | |||
55 | |||
56 | 1 | Gareth Eaton | <pre> |
57 | sudo rsync -avP source_directory/ /var/www/html/nextcloud/data/ |
||
58 | 5 | Gareth Eaton | |
59 | sudo chown -R www-data:www-data /var/www/html/nextcloud |
||
60 | sudo chmod -R 775 /var/www/html/nextcloud |
||
61 | 1 | Gareth Eaton | </pre> |
62 | |||
63 | 3 | Gareth Eaton | Step 6: Restore the Database |
64 | 1 | Gareth Eaton | |
65 | 3 | Gareth Eaton | Restore the database using this command: |
66 | |||
67 | 1 | Gareth Eaton | <pre> |
68 | 3 | Gareth Eaton | mysql -u your_mysql_username -p your_database_name < your_backup_file.sql |
69 | </pre> |
||
70 | |||
71 | For example: |
||
72 | |||
73 | 4 | Gareth Eaton | <pre> |
74 | mysql -u nextcloud -p nextcloud < nextcloud-sqlbkp.bak |
||
75 | 5 | Gareth Eaton | </pre> |
76 | 1 | Gareth Eaton | |
77 | 5 | Gareth Eaton | |
78 | Take it out of maintenance mode by running the following command: |
||
79 | |||
80 | <pre> |
||
81 | sudo -u www-data php occ maintenance:mode --off |
||
82 | 2 | Gareth Eaton | </pre> |
83 | 3 | Gareth Eaton | |
84 | 2 | Gareth Eaton | Step 7: Verify Access and Data |
85 | 1 | Gareth Eaton | |
86 | You should now be able to access your Nextcloud. Verify that your users and files are intact. |
||
87 | 5 | Gareth Eaton | |
88 | Go to the Administration Setting and fix an problems that are showing up. |