Skip to content

scubamuc/scubamuc.github.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

SCUBA's self hosted Nextcloud snap server

scubamuc

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


System specs

Hardware

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

OS & Software

Requirements:

LXD-server setup

LXD-backup-server setup


Procedure

Install Nextcloud-snap in LXC container on LXD server


Snap backup, restore & migrate

Backup Nextcloud snap with Snap snapshot

snapshot documentation

  • 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.

rotating Snap snapshot script

Restore Snap snapshot using Snap restore

  • 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"


LXC container snapshot / backup & restore

Backup LXC container with snapshot/image & restore in shell scripted

This works fine as scripted cronjob, 0 downtime.

rotating LXC container snapshot script

Backup & Restore LXC container

  • lxc image import $PATH/to/$IMAGENAME.tar.gz --alias $IMAGENAME
  • lxc launch $IMAGENAME $CONTAINERNAME

See also personal LXD-LXC Wiki (just notes)