mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 17:31:34 +01:00
Automate restic restore command creation
This commit is contained in:
parent
731f0ec615
commit
e6989963c7
6 changed files with 70 additions and 95 deletions
|
|
@ -1,9 +1,4 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.custom.services.nextcloud;
|
||||
|
||||
|
|
@ -28,20 +23,14 @@ in
|
|||
"${dataDir}/db.dump"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "nextcloud-restore";
|
||||
text = ''
|
||||
sudo --user=${user} bash -c "
|
||||
${lib.getExe' config.services.nextcloud.occ "nextcloud-occ"} maintenance:mode --on
|
||||
restic-nextcloud restore latest --target /
|
||||
pg_restore --clean --if-exists --dbname nextcloud ${dataDir}/db.dump
|
||||
${lib.getExe' config.services.nextcloud.occ "nextcloud-occ"} maintenance:mode --off
|
||||
"
|
||||
restoreCommand = {
|
||||
preRestore = "${lib.getExe' config.services.nextcloud.occ "nextcloud-occ"} maintenance:mode --on";
|
||||
postRestore = ''
|
||||
pg_restore --clean --if-exists --dbname nextcloud ${dataDir}/db.dump
|
||||
${lib.getExe' config.services.nextcloud.occ "nextcloud-occ"} maintenance:mode --off
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue