Backup (restic)
Daily backup with restic to SFTP, S3, a REST server or a local path – /etc, /root, /var/lib, the app's data and database dumps. Target: backup_repository in /etc/iac/settings.env
Add to a guest
In the guest as root – container and VM alike:
update --add-modules backupRuns a normal update and installs the module on the way.
From the Proxmox node, without logging in:
pct exec <ID> -- update --add-modules backup # container
ssh root@<IP> update --add-modules backupChoose when creating a guest
Without a dialog, on the Proxmox node:
IAC_NONINTERACTIVE=1 var_modules=auto-update,backup \
bash -c "$(curl -fsSL https://haypack.dev/<app>/ct.sh)"var_modules replaces the app's preselection – keep auto-update in the list if you want it. Interactive: choose “advanced” in the dialog, or tick the module in the generator on the app page.
Remove
update --remove-modules backupRemoves the module's packages, services, firewall rules and configuration again. Data stays.
Details
Backs up the guest every day with restic: /etc, /root, /home,
/srv, /var/lib, the app’s data and – if active – PostgreSQL and MariaDB as a dump. It keeps
7 daily, 4 weekly and 6 monthly snapshots.
Set the target
After adding the module only the target is missing, in /etc/iac/settings.env:
backup_repository=sftp:backup@nas.example:/srv/restic/myhost # SFTP (SSH key of root)
backup_repository=s3:https://s3.example/bucket/myhost # S3
backup_repository=rest:https://backup.example/myhost # restic REST server
Credentials, e.g. for S3, go into /etc/iac/backup.env
(AWS_ACCESS_KEY_ID=…, AWS_SECRET_ACCESS_KEY=…).
Use it
iac-backup # back up now (otherwise automatically at night)
iac-backup snapshots # existing snapshots
iac-backup restore latest --target /root/restore # restore
Keep
backup_passwordfrom/etc/iac/settings.envin a safe place! The module generates it once per guest. Without this password no backup can be read – not even when the guest is lost.
More paths: /etc/iac/backup.local.paths (one path per line). When the module is removed, the
repository, the password and the last dumps stay.
Sichert den Gast jeden Tag mit restic: /etc, /root, /home,
/srv, /var/lib, die Daten der App und – falls aktiv – PostgreSQL und MariaDB als Dump. Es
bleiben 7 tägliche, 4 wöchentliche und 6 monatliche Snapshots.
Ziel setzen
Nach dem Hinzufügen des Moduls fehlt nur das Ziel, in /etc/iac/settings.env:
backup_repository=sftp:backup@nas.example:/srv/restic/myhost # SFTP (SSH-Schlüssel von root)
backup_repository=s3:https://s3.example/bucket/myhost # S3
backup_repository=rest:https://backup.example/myhost # restic-REST-Server
Zugangsdaten, etwa für S3, gehören in /etc/iac/backup.env
(AWS_ACCESS_KEY_ID=…, AWS_SECRET_ACCESS_KEY=…).
Benutzen
iac-backup # jetzt sichern (sonst automatisch nachts)
iac-backup snapshots # vorhandene Snapshots
iac-backup restore latest --target /root/restore # wiederherstellen
backup_passwordaus/etc/iac/settings.envsicher aufbewahren! Das Modul erzeugt es einmal pro Gast. Ohne dieses Passwort lässt sich kein Backup lesen – auch nicht, wenn der Gast verloren ist.
Weitere Pfade: /etc/iac/backup.local.paths (ein Pfad pro Zeile). Wird das Modul entfernt,
bleiben das Repository, das Passwort und die letzten Dumps.
