Skip to content

Commit

Permalink
remove deskapp backup over cifs
Browse files Browse the repository at this point in the history
  • Loading branch information
appaquet committed Oct 21, 2024
1 parent 8898f9c commit 771248b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 56 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 5 additions & 26 deletions nixos/deskapp/home-backup.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, secrets, config, ... }:
{ pkgs, config, ... }:

let
exclude = [
Expand Down Expand Up @@ -31,13 +31,15 @@ let
];
foldersStr = builtins.concatStringsSep " " (map (x: "${homePath}/" + x) folders);

backupMount = "/mnt/deskapp_backup";
sshCmd = "${pkgs.openssh}/bin/ssh";
nasHost = "192.168.0.20";
nasDest = "/volume1/backup_deskapp/home/";
backupScript = pkgs.writeShellScriptBin "backup-home" ''
set -x
for FOLDER in ${foldersStr}; do
echo "Syncing $FOLDER"
${pkgs.rsync}/bin/rsync -av --progress ${excludeStr} --delete --delete-excluded $FOLDER ${backupMount}/home/ || true
${pkgs.rsync}/bin/rsync -av --progress ${excludeStr} --delete -e ${sshCmd} --delete-excluded $FOLDER ${nasHost}:${nasDest} || true
done
'';
in
Expand All @@ -47,29 +49,6 @@ in
pkgs.cifs-utils
];

fileSystems."${backupMount}" = {
device = "//192.168.0.20/backup_deskapp";
fsType = "cifs";
options =
let
automount_opts_list = [
"vers=3.0"
"uid=appaquet"
"gid=users"
# don't mount with fstab, but with systemd & make it resilient to network failures
# from https://discourse.nixos.org/t/seeking-help-with-mounting-samba-cifs-behind-a-vpn-currently-using-autofs/35436/6
"noauto"
"x-systemd.automount"
"x-systemd.idle-timeout=60"
"x-systemd.device-timeout=5s"
"x-systemd.mount-timeout=5s"
"credentials=${secrets.deskapp.nasappCifs}"
];
automount_opts = builtins.concatStringsSep "," automount_opts_list;
in
[ automount_opts ];
};

systemd.services."backup-home" = {
serviceConfig = {
Type = "oneshot";
Expand Down
31 changes: 5 additions & 26 deletions nixos/deskapp/vms-backup.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{ pkgs, secrets, ... }:
{ pkgs, ... }:

let
backupMount = "/mnt/deskapp_backup_vms";
vmsDir = "/mnt/secondary/vms";

sshCmd = "${pkgs.openssh}/bin/ssh";
nasHost = "192.168.0.20";
nasDest = "/volume1/backup_deskapp_vms/";
backupScript = pkgs.writeShellScriptBin "backup-vms" ''
set -xe
Expand Down Expand Up @@ -32,7 +34,7 @@ let
chmod -R u+wr,g+wr,a+r .
# Backup
${pkgs.rsync}/bin/rsync -av --progress --delete --whole-file --sparse . ${backupMount}/
${pkgs.rsync}/bin/rsync -av --progress --delete --whole-file -e ${sshCmd} --sparse . ${nasHost}:${nasDest}
'';
in

Expand All @@ -41,29 +43,6 @@ in
pkgs.cifs-utils
];

fileSystems."${backupMount}" = {
device = "//192.168.0.20/backup_deskapp_vms";
fsType = "cifs";
options =
let
automount_opts_list = [
"vers=3.0"
"uid=appaquet"
"gid=users"
# don't mount with fstab, but with systemd & make it resilient to network failures
# from https://discourse.nixos.org/t/seeking-help-with-mounting-samba-cifs-behind-a-vpn-currently-using-autofs/35436/6
"noauto"
"x-systemd.automount"
"x-systemd.idle-timeout=60"
"x-systemd.device-timeout=5s"
"x-systemd.mount-timeout=5s"
"credentials=${secrets.deskapp.nasappCifs}"
];
automount_opts = builtins.concatStringsSep "," automount_opts_list;
in
[ automount_opts ];
};

systemd.services."backup-vms" = {
serviceConfig = {
Type = "oneshot";
Expand Down
2 changes: 1 addition & 1 deletion secrets

0 comments on commit 771248b

Please sign in to comment.