Some scripts to backup your local nextcloud instance running on a Raspberry Pi (or alike) with nextcloudpi.
This scripts uses:
- the wonderful kopia for backup (end-to-end encrypted, incremental, de-dup (using hashes and splitting to save only changed parts of large files), compressed, fast!)
- optional: use zstd to compress DB dumps (gzip otherwise)
- save backup to Storj cloud storage (but you could connect to another kopia repository if you want, of course. *However, Storj currently offers 150 GB for free and is cheaper than all other providers I found. And I like the idea of the distributed approach with open source software that anyone can use and sign up to host another Storj node. I don't really understand the details of 'erasure codes' as redundancy approach 🤔, but it sounds to me like someone really thought in depth about this... 🫣)
- the files in this repo should be checked out to
/home/kopia
as some paths are hardcoded... - create your kopia repository, e.g. at Storj
- connect to the kopia repository, e.g. using
storj-connect-repo.sh
- in this case you should write your
.env
file containing your credentials
- in this case you should write your
- NOTE: currently you need to adjust the paths in
kopia-run-backup.sh
- setup and enable systemd timers by running
setup-systemd.sh
The timers run the kopia-run-backup.sh
as root (which you also could run manually). No user interaction is required.
The script supports two modes: normal (executed every 4 hours) and full (daily).
This will backup
- compressed mysql DB dump (using zstd if available, gzip otherwise)
- nextcloud's data dir, containing all files
- the backup setup at
/home/kopia
- complete system backup including the nextcloud from
/
In addition to the normal backup, this
- sets nextcloud's maintenance mode to avoid any action to produce an inconsistent state
- shutdown mysql and snapshot the DB directory (and restart mysql afterwards)
- restore maintenance mode to what it was before
bucket=kopia
access-key=... your credentials from Storj...
secret-access-key=... your credentials from Storj...