🍔 backup tool
Find a file
JMARyA db850005b4
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
Merge pull request 'Update Rust crate openssl to v0.10.75' (#8) from renovate/openssl-0.x-lockfile into main
Reviewed-on: #8
2025-12-05 21:03:06 +00:00
.woodpecker
docs
nixos conf reference 2025-11-17 23:29:39 +01:00
src
systemd
.gitignore
Cargo.lock Merge pull request 'Update Rust crate openssl to v0.10.75' (#8) from renovate/openssl-0.x-lockfile into main 2025-12-05 21:03:06 +00:00
Cargo.toml
flake.lock
flake.nix
PKGBUILD
README.md
renovate.json

🍔 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