ZFS snapshots combined with replication to another box. That and a cronjob on packaging up my compose/config files.
Self-Hosted Main
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
For Example
- Service: Dropbox - Alternative: Nextcloud
- Service: Google Reader - Alternative: Tiny Tiny RSS
- Service: Blogger - Alternative: WordPress
We welcome posts that include suggestions for good self-hosted alternatives to popular online services, how they are better, or how they give back control of your data. Also include hints and tips for less technical readers.
Useful Lists
- Awesome-Selfhosted List of Software
- Awesome-Sysadmin List of Software
I build my own docker images. All my images are build to run as set id / guid when specified in ansible.
This way only my servicedaemon can do stuff. Also makes sure i never have issues with borgbackup etc.
I have a backup-script (running as root) that
- stops all containers
- runs the restic-backup
- starts all containers
I had this before but this created struggles with some containers since they do start specific checks and scans during startup which resulted in high cpu and disk load.
Since unraid supports zfs, i am using this for the docker stuff and do snapshots to external disk as backup
no need to stop containers anymorw
If you work with databases it’s still safer to stop incoming data for the time of the backup. I don’t know why a higher CPU load would be a problem, those checks don’t run long or do so much your system would be under much stress. Do your backups at 3am if you still think the minute of highe load would cause any problems.
A simpler method would be to stop/start the Docker daemon instead of containers, it works smoothly.
Don't run docker as root, don't run containers as root, pretty simple to be honest.
KISS method: Script that copy the data on the fly to the /tmp dir, compress it, encrypt it and move it to destination using rclone. Running every hour, 4 hours or 24 hours, depending the container.
Never fails. The backups nor the restore.
I mean, snapshotting and piping it to an rclone mount is arguably simpler than trying to do your own ad hoc file syncronization, also does not require 2x the storage space.
Can't you run a restic container where you mount everything? If the restic container is insecure, everything is of course.
But yes, I also migrated to rootless Podman for this reason and a bunch of others.
I used to let root start the backup job
I converted they to use Podman.
This is one reason I prefer FreeBSD jails. They are each in a separate ZFS filesystem, with a separate filesystem for configuration files. So all I have to do is regular snapshots and send those to a backup pool.
I do this at the file system level, not the file level, using zfs.
Unless the container has a database, I use zfs snapshots. If it has a database, my script dumps the database first and then does a ZFS snapshot. Then that snapshot is sent via sanoid to a zfs disk that is in a different backup pool.
This is a block level backup, so it only backs up the actual data blocks that changed.
First, I try not to have it owned by root. But some containers have special privileges that need to be followed.
So rsync -O will copy the directory retaining permissions and ownership of all files.
Don’t backup the container!!
Map volumes with your data to physical storage and then simply backup those folders with the rest of your data. Docker containers are already either backed up in your development directory (if you wrote them) or GitHub so like the operating system itself, no need tk backup anything. The whole idea of Docker is the containers are ephemeral. They are reset at every reboot.
For backups I use Nautical Backup.
For the "owned by root" problem, I ensure all my docker compose files have [P]UID and [P]GID set to 1000 (the user my docker runs under). All my 20 containers have no issue running like this.
How are you launching your containers? Docker compose is the way, I have set the following in all mine:
environment:
- PUID=1000
- PGID=1000
user:
1000:1000
Do u add bothe the user and env variables or just one?
Do u add bothe the user and env variables or just one?
I add both because why not. It doesn't hurt.
only backup of the data i need to backup (mapped volumes).
Restore: create fresh container and map volumes again.
From my basic selfhosted experience... I run kopia as root , my shit uses bind mounts so all I care about is in that directory.
And so far it works fine, to just down old, rename the directory, copy from nightly backup back the directory and start container.
But yeah if there is something I care about I schedule database dumps like here in bookstack or vaultwarden..
To have something more if shit would not work start.
Try to not run containers as root?
i don't, i created a docker VM (and a couple others) and then i backup the VMs (proxmox + PBS make this very easy) with all their data in /home/docker/config/*
i used to have them run off networked storage but i found it to be to slow/have other issues
this also means for the primary important services that VM runs in HA and moves to another node when needed
sudo crontab -e
I have my config and data volumes mounted to a share on truenas, that share replicates its snapshots to another truenas server. This is likely not ideal for everyone, but it works for me. My friend that also uses docker has it backed up with duplicati.