# Nexctloud Journey to install Nextcloud on an Ubuntu Server 20.04 LTS instance. ## Install Installed by checking _nexcloud_ on Ubuntu installation wizard. Can be installed later with **snap**. ### Configure proxy _Use case : ports 80 and 443 are directed to my raspberry pi (with local IP 192.168.1.100), and domain name cloud.me.ovh must be redirected to my nexcloud server on IP 192.168.1.110_ Configure proxy setting on pi (more info on private httpd repo): ```apache ServerName cloud.me.ovh ProxyPreserveHost On ProxyRequests Off ProxyPass / http://192.168.1.110/ ProxyPassReverse / http://192.168.1.110/ ``` Add a file `proxy.config.php` in folder _/var/snap/nextcloud/current/nextcloud/config_ with following content : ```php ['192.168.1.100'], ]; ``` ### Trust domain Add a file `trust_domain.config.php` in folder _/var/snap/nextcloud/current/nextcloud/config_ with following content : ```php [ 'cloud.me.ovh', '192.168.1.110', ], ]; ``` No need to restart system, config is taken into account at web page reload. ### Enforce security #### On proxy Follow [official instructions on Nextcloud doc](https://docs.nextcloud.com/server/latest/admin_manual/installation/harden_server.html) To enable *mod_headers* on HTTPD : `a2enmod headers` #### On snap installation `sudo nextcloud.enable-https lets-encrypt` ### Other fixes As an admin, go to _Overview_ in the _Administration_ panel from _Settings_. Nexctloud will scan your instance and give you instructions. ### TURN Talk Talk can fail for some users behind annoying firewalls or symmetric NAT. That can be fixed by using a [TURN server](https://nextcloud-talk.readthedocs.io/en/latest/TURN/). ### Synchronisation on Android Follow these instructions [Nextcloud sync documentation](https://docs.nextcloud.com/server/20/user_manual/en/pim/sync_android.html). Warning : if you use an apache proxy, use [overwriteprotocol](https://docs.nextcloud.com/server/12/admin_manual/configuration_server/config_sample_php_parameters.html#proxy-configurations) instruction to force `https` in redirections. ## Use OCC In Ubuntu snap, you can invoke nextcloud CLI with `nextcloud.occ` command. [Full documentation about OCC on official doc](https://docs.nextcloud.com/server/20/admin_manual/configuration_server/occ_command.html) ### Migrate data by CLI First put your files in user space : ```sh sudo cp -a Music /var/snap/nextcloud/common/nextcloud/data/jovian/files/ ``` Then fix ownership of new folder : ```sh sudo chown -R root:root Music ``` Refresh Nextcloud cache : ``` sudo nextcloud.occ files:scan --path="/jovian/files/Music" ``` ## Apps ### Collabora online Install via CLI with : ``` sudo -u www-data php -d memory_limit=512M nextcloud.occ app:install richdocumentscode ``` ## Migrate to a new installation ### References [Official Nextcloud guide to migrate from one server to another](https://docs.nextcloud.com/server/latest/admin_manual/maintenance/migrating.html) ### Chronogram 1. Change DNS record (anticipate propagation time) 2. Make a fresh installation on a new server 21. Install OS 22. Set a unic hostname 23. Assign a static IP address 24. Update and reboot 3. Backup old installation and import data on a new server 30. Stop services `sudo systemctl stop 'snap.nextcloud.*'` 31. Change ownership of `common` and `current` in `/var/snap/nextcloud` to SSH user on target 32. Transfer files these 2 folders on the new instance (be sure the same version is installed) 33. Restore folder ownership 34. Start services `sudo systemctl start 'snap.nextcloud.*'` 4. Local test 41. Browser access 42. Files available 5. Make your instance available 51. Check DNS redirection 52. Set up reverse-proxy 6. Online test 61. Browser access 62. Files available 63. PC sync client 64. Android sync client 65. Agenda sync 66. Tasks sync 67. Money buster sync ### Switch to a reverse-proxy Disable HTTPS with `nextcloud.disable-https` Configure HTTPS on reverse-proxy. ### Trouble shoot migration Apps are not working (example from my own migration : *Contacts* and *Tasks* not working because of javascript file not found. I had some errors after `rsync` about those files. That might be related. ## Manage disks ### Check health #### Check RAID ``` cat /proc/mdstat ``` #### Check individual HDD ``` smartctl --scan sudo smartctl -a /dev/sdc ``` If one the tested disk is failing, write down its serial number and continue with the replacement procedure. ### Replace the disk 0. RAID disconnection 01. `cat /proc/mdstat` 02. `mdadm --manage /dev/md0 --fail /dev/sdy1` 03. `cat /proc/mdstat` 04. `mdadm --manage /dev/md0 --remove /dev/sdy1` 05. `cat /proc/mdstat` 1. Physical replacement 11. Shut down the server 12. Spot the HDD to remove based on its serial number 13. Replace it by the new one 14. Boot the server 15. Mark the retrieved HDD as dead 2. RAID update 21. `cat /proc/mdstat` 22. Become superuser 23. `fdisk -l` -> spot the device with no partition `/dev/sdz` 24. Copy partition information 241. For MBR partitioning (legacy) : `sfdisk -d /dev/sdx | sfdisk /dev/sdz` 242. For GPT partitioning : `sgdisk -R /dev/sdz /dev/sdx` then `sgdisk -G /dev/sdz` 25. `fdisk -l` -> check that `/dev/sdz` is partitioned 26. `mdadm --manage /dev/md0 --add /dev/sdz1` 27. `cat /proc/mdstat` 28. Hope you first disk won't die during recovery