for a self hosted Nextcloud I turned to Ubuntu Server and LXD to create an LXC container for Nextcloud snap. There is a great community behind Nextcloud snap. The greatness of Linux together with supported hardware enables anyone to run a 24/7 Nextcloud server.
My goal is a simple safe and reliable setup with ample resources for 5+ family users, affordable, efficient and low maintenence. My day job is software support for a leading WMS. I'm an avid scuba diver and enjoy Linux and FOSS. I'm a dad and husband thus I'm not keen on spending much of my free time doing server-maintenence.
Quicklinks
Requirements:
- Affordable, efficient, small
- Small energy footprint
- Linux compatible
- Ample resources - (5+ users)
- Low maintenence - (uptime 24/7)
- Redundancy - (failover, cold-standby & backup)
- Multiple services - (Nextcloud, Webserver, FW, VPN, DNS, Proxy, Docker)
2x Lenovo ThinkCentre M92p Tiny (refurbished) - stackable 1xServer & 1xBackup
- CPU: Intel Core i5-3470T
- PSU: 16W/12W load/idle
- RAM: 16GB
- SSD: 500GB
Requirements:
- Ubuntu Server (easy setup & maintenence, unattended updates & updgrades)
- Nextcloud snap (easy setup & automated updates)
- LXD (multiple LXC containers)
- Packages:
cockpit, docker.io, mc, openssh-server, sysstat, tmux
- Snaps:
htop, lxd, lnav, nextcloud
- Bridged network (IP from DHCP)
- Multiple LXC containers (Nextcloud, Webserver, FW, VPN, DNS, Proxy, Docker)
- Automated rotating snapshots (daily) 0 downtime 24/7
- Automated synchronisation to LXD-backup-server (weekly)
- Automated rotating backup to NAS (monthly)
- Identical setup to LXD-server -- cold-standby
- Bridged network (IP from DHCP)
- Multiple synchronised LXC containers (Nextcloud, Webserver, FW, VPN, DNS, Proxy, Docker)
- WOL
ctr-wake
(weekly) container synchronisation - WOL (manual) failover
- Prepare LXD server with Ubuntu Server and bridged network
- Prepare LXC container with Ubuntu Server
- Install Nextcloud snap in LXC-container
- Set FQDN in
/etc/hosts
in LXC-container - Nextcloud snap handles Lets-Encrypt certificate automatically with
nextcloud.enable-https lets-encrypt
- optionally handle certificates with reverse Proxy or NGINX-Proxy-Manager
- Configure Nextcloud and regain control over your data
- snap stop nextcloud (optional)
- snap save nextcloud
- snap start nextcloud (optional, see above)
- find snapshot in
/var/lib/snapd/snapshots
and copy/move to wherever
This works fine as weekly automatic cronjob (as root) and has the added convenience of easy snap transfer to different server when needed. Thus always 4 weeks of snap-snapshots on backup media.
- when moving to new device, be sure to install Nextcloud snap first
- snap restore replaces previous installation incl. certs, DB and data
- see documentation in
man snap
and snapcraft
1. copy compressed file (*.zip) from backup media to /var/lib/snapd/snapshots
2. discover snapshot-ID using snap saved
3. issue command sudo snap restore "snapshot-ID"
Backup LXC container with snapshot/image & restore in shell scripted
- LXC container snapshot scripted
- LXC container image from snapshot scripted
- LXC image sync/copy/move to wherever Syncronise/Copy containers between LXD nodes
- LXC image rotate scripted
This works fine as scripted cronjob, 0 downtime.
rotating LXC container snapshot script
lxc image import $PATH/to/$IMAGENAME.tar.gz --alias $IMAGENAME
lxc launch $IMAGENAME $CONTAINERNAME
See also personal LXD-LXC Wiki (just notes)