🍔 backup tool
Find a file
JMARyA 832ed99555
Some checks failed
ci/woodpecker/push/build/2 Pipeline is pending
ci/woodpecker/push/container-manifest Pipeline is pending
ci/woodpecker/push/container/2 Pipeline is pending
ci/woodpecker/push/build/1 Pipeline failed
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/container/1 Pipeline was successful
conf reference
2025-11-17 23:29:39 +01:00
.woodpecker fix 2025-10-31 18:50:24 +01:00
docs add ntfy passfile 2025-10-19 07:04:06 +02:00
nixos conf reference 2025-11-17 23:29:39 +01:00
src add ntfy passfile 2025-10-19 07:04:06 +02:00
systemd add restic forget + config schema 2025-10-19 04:45:21 +02:00
.gitignore add nix 2025-09-10 22:24:05 +02:00
Cargo.lock Update Rust crate schemars to v1.1.0 2025-11-05 20:00:45 +00:00
Cargo.toml add restic forget + config schema 2025-10-19 04:45:21 +02:00
flake.lock add nix 2025-09-10 22:24:05 +02:00
flake.nix nix fns 2025-11-02 16:41:46 +01:00
PKGBUILD refactor systemd 2025-07-26 22:40:27 +02:00
README.md fix 2025-11-08 14:53:15 +01:00
renovate.json Add renovate.json 2025-06-21 21:35:41 +00:00

🍔 BK

bk is a backup utility.

Configuration

You run bk against a configuration file in TOML format.

See Configuration for more details.

I want to backup

Requirements

You need at least one backup location.

This can be either:

Local Filesystem Target

To use a local filesystem:

[restic_target.my_restic_target]
repo = "/backup/repo.restic"
passphrase = "password"

SSH Remote Target

Add this to your bk.toml configuration:

[restic_target.offsite]
repo = "sftp:myhost:/backup/repo.restic"
passphrase = "password"

For simple auth, add this to .ssh/config:

Host myhost
    Hostname <hostname>
    User <user>
    IdentityFile <ssh_key>

S3 Remote Target

#todo

Local Machine

Nixos

To backup a Nixos machine, add inputs.bk.url = "git+https://git.hydrar.de/jmarya/bk"; to your flake inputs.

To use bk include the Nixos Module at inputs.bk.nixosModules.bk.

Sample configuration:

{
  services.bk = {
    enable = true;

    # The three options below is all thats needed for a basic backup

    # State folders to backup
    state = [
      "/somepath"
    ]:

    # Backup repository
    repo = "sftp:myhost:/backup/repo.restic"

    # Options for the repository
    repoOptions = {
      passphrase_file = "/secret";
    }

    # Global configuration settings
    globalSettings = { };

    # Manual Configuration Blocks which get merged. Can contain raw config options or made with helper functions from inputs.bk.lib.
    settings = [
      # mkBk automatically sets up paths, targets and a basic restic operation
      (inputs.lib.bk.makeBk {
              paths = [ "/otherpath" ];
              repo = "/otherrepo";
              # Extra Options for the restic operation
              extraOptions = {};
              # Extra options for the paths
              extraPathOptions = { };
              # extra options for the target
              extraTargetOptions = { };
      })
    ];

  };
}

This automatically builds a /etc/bk.toml config file and sets up systemd services for backup once a day.

Home Folder

Create systemd units:

# /home/<user>/.config/systemd/user/backup.service
[Unit]
Description=Home Folder Backup

[Service]
Type=simple
ExecStart=/usr/bin/bk /home/<user/.config/bk.toml
StandardOutput=journal
StandardError=journal
# /home/<user>/.config/systemd/user/backup.timer
[Unit]
Description=Scheduled backup

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target

Then a config file:

# /home/<user>/.config/bk.toml
[path.homedir]
path = "/home/<user>"

[restic_target.offsite]
repo = "<repo>"
passphrase = "<passphrase>"

[[restic]]
src = ["homedir"]
targets = ["offsite"] 

exclude = [
    ".cache", # Caches
    ".local/share/Trash", # System Trash
    ".local/share/containers" # Containers
]
exclude_caches = true
one_file_system = true

concurrency = 4

Run first backup and tests with:

bk ~/.config/bk.toml

And enable backups with:

systemctl --user enable --now backup.timer