Start configuring btrbk for nextcloud2
TODO: - cron to run btrbk hourly - format and mount drives
This commit is contained in:
parent
78caf0048a
commit
1f7f05d1a0
4
deploy.sh
Executable file
4
deploy.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export LOCAL_KEY=/etc/nix/cache-priv-key.pem
|
||||
sudo nix run github:serokell/deploy-rs $1
|
101
flake.nix
101
flake.nix
|
@ -8,8 +8,51 @@
|
|||
};
|
||||
|
||||
outputs = { self, deploy-rs, image-builder, nixpkgs }:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
system = "aarch64-linux";
|
||||
};
|
||||
|
||||
btrbkPrimary = { subvolumes ? [ ] }: {
|
||||
snapshot_dir = "@snapshots";
|
||||
subvolume = builtins.foldl'
|
||||
(acc: subvol: acc // {
|
||||
${subvol} = { };
|
||||
})
|
||||
{ }
|
||||
subvolumes;
|
||||
};
|
||||
|
||||
btrbkSecondary = { target-dir, subvolumes ? [ ] }: {
|
||||
target = "send-receive ${target-dir}";
|
||||
subvolume = builtins.foldl'
|
||||
(acc: subvol: acc // {
|
||||
${subvol} = {
|
||||
snapshot_dir = "@snapshots";
|
||||
snapshot_preserve_min = "all";
|
||||
snapshot_create = "no";
|
||||
};
|
||||
})
|
||||
{ }
|
||||
subvolumes;
|
||||
};
|
||||
|
||||
nextcloudSubvolumes = [
|
||||
"@nc-config"
|
||||
"@nc-data"
|
||||
"@postgres"
|
||||
"@redis"
|
||||
"@gitea"
|
||||
"@gitea-conf"
|
||||
"@pihole"
|
||||
"@papermc"
|
||||
"@docker-cfg"
|
||||
"@garage"
|
||||
"@garage-config"
|
||||
];
|
||||
in
|
||||
{
|
||||
modules.shared = {
|
||||
modules.shared = { extraPackages ? [ ] }: {
|
||||
services.openssh.settings.PasswordAuthentication = false;
|
||||
|
||||
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default)
|
||||
|
@ -17,11 +60,47 @@
|
|||
# Enables the generation of /boot/extlinux/extlinux.conf
|
||||
boot.loader.generic-extlinux-compatible.enable = true;
|
||||
|
||||
users.users.asonix = {
|
||||
isNormalUser = true;
|
||||
description = "Tavi";
|
||||
extraGroups = [ "wheel" ];
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3+mNUlokSKZQNXJAuGm2LCHelKuElWLJArzIYZQYEPbrFaE+J8VtfNbMMD1qVI21ksfcqvFQW4aiP4+BFDxTOGW0uBmUHWKxkyyU39y2yhnsa+svwwIooc+Iwkxw0atzSMEBb94UaZlq9cKMSnG9RGeRFqfYnW2s49wpU79wk6zEFUuOHCMKn4R7zqkPac7IyjxZeKlspY3fOasNH4zyrkbhEOlvrwEOdRNTRNCWWzDcinIVZjfmErHlSynshx9yLnCGkLBxHSxgI2TVyR3RlQ3aGbHtB3QN5X7/T/dwXJFJ11P1Q2bC3XP3hHCogDqXcPvDTFSQEM/mZuFcKNbsn asonix@asonix-tower"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/" =
|
||||
{
|
||||
device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
btrbk
|
||||
] ++ extraPackages;
|
||||
|
||||
services.btrbk = {
|
||||
sshAccess = [
|
||||
{
|
||||
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTqU3EvTgY5/e9m6YyQWypQPK58t9iPmPnPYAvnODGB asonix@lionheart";
|
||||
roles = [ "source" "info" "send" ];
|
||||
}
|
||||
];
|
||||
extraPackages = with pkgs; [ xz ];
|
||||
instances.btrbk.settings = {
|
||||
transaction_log = "/var/log/btrbk.log";
|
||||
stream_buffer = "512m";
|
||||
snapshot_preserve_min = "2d";
|
||||
snapshot_preserve = "35d 20w 12m";
|
||||
target_preserve_min = "24h";
|
||||
target_preserve = "24h 7d";
|
||||
archive_preserve_min = "latest";
|
||||
archive_preserve = "12m 10y";
|
||||
ssh_user = "btrbk";
|
||||
ssh_identity = "/etc/btrbk/ssh/backup-ssh-key";
|
||||
backend_remote = "btrfs-progs-sudo";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nixosConfigurations.nextcloud2 =
|
||||
|
@ -29,9 +108,27 @@
|
|||
system = "aarch64-linux";
|
||||
modules = [
|
||||
image-builder.packages.aarch64-linux.modules.rockPro64v2
|
||||
self.modules.shared
|
||||
(self.modules.shared
|
||||
{
|
||||
extraPackages = with pkgs; [
|
||||
docker
|
||||
docker-compose
|
||||
];
|
||||
})
|
||||
{
|
||||
networking.hostName = "nextcloud2";
|
||||
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
services.btrbk.instances.btrbk.settings.volume = {
|
||||
"ssh://192.168.20.21/btrfs/hdd" = btrbkSecondary {
|
||||
target-dir = "/btrfs/hdd/@snapshots";
|
||||
subvolumes = nextcloudSubvolumes;
|
||||
};
|
||||
# "/btrfs/hdd" = btrbkPrimary {
|
||||
# subvolumes = nextcloudSubvolumes;
|
||||
# };
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue