blog/content/posts/restic-nixos-hetzner.md
2026-02-16 14:48:06 +00:00

40 lines
1.1 KiB
Markdown

---
title: Backing up nixos state with restic
date: 2026-02-16
tags:
- nixos
- restic
draft: true
---
I'm writing this so I can hopefully remember what I did in six months.
As hard as you try to eliminate all state from your computing life with nixos, the fact remains that you can't get rid of all of it.
For example, I run forgejo on my VPS.
Now I have my config which means I could set up a forgejo instance just how I like it if everything went to pot.
But that wouldn't bring back any of the repos I had there previously.
This is the method I cooked up for backing up some of those important bits and bob on my VPS.
```nix
{ config, ... }: {
services.restic = {
backups."hetzner-storage-box" = {
initialize = true;
user = "root";
passwordFile = "/etc/nixos/secrets/restic";
paths = [
"${config.services.forgejo.stateDir}"
];
repository = "sftp:user@storagebox:/remotelab";
extraOptions = [
"sftp.command='ssh user@storagebox -i /root/.ssh/id_ed25519 -s sftp'"
];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
};
};
};
}
```