Fix external backup again
This commit is contained in:
@@ -6,39 +6,18 @@ let
|
||||
|
||||
DEVICE=/dev/disk/by-path/pci-0000:00:12.0-ata-2-part1
|
||||
|
||||
cryptsetup luksOpen ''${DEVICE} external-drive
|
||||
${pkgs.cryptsetup}/bin/cryptsetup luksOpen ''${DEVICE} external-drive
|
||||
mkdir -p /mnt/external-drive
|
||||
mount /dev/mapper/external-drive /mnt/external-drive
|
||||
'';
|
||||
|
||||
cb-sync = pkgs.writeScriptBin "cb-sync" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
set -e
|
||||
|
||||
# Check, if the something is mounted in our sycdir
|
||||
if grep -qs '/mnt/external-drive' /proc/mounts
|
||||
then
|
||||
echo "fine"
|
||||
else
|
||||
echo "Please plug in a backup drive and mount it using cb-mount"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SNAPSHOT_NAME=$(${pkgs.borgbackup}/bin/borg list --last 1 --short /mnt/palladium/clerie-backup)
|
||||
${pkgs.borgbackup}/bin/borg mount /mnt/palladium/clerie-backup::$SNAPSHOT_NAME /mnt/clerie-backup-mount
|
||||
${pkgs.bindfs}/bin/bindfs /mnt/clerie-backup-mount/mnt/clerie-backup /mnt/clerie-backup
|
||||
${pkgs.borgbackup}/bin/borg create /mnt/external-drive/clerie-backup::$SNAPSHOT_NAME /mnt/clerie-backup
|
||||
umount /mnt/clerie-backup
|
||||
${pkgs.borgbackup}/bin/borg unmoumt /mnt/clerie-backup-mount
|
||||
'';
|
||||
|
||||
cb-unmount = pkgs.writeScriptBin "cb-unmount" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
|
||||
umount /mnt/external-drive
|
||||
cryptsetup luksClose external-drive
|
||||
${pkgs.cryptsetup}/bin/cryptsetup luksClose external-drive
|
||||
'';
|
||||
|
||||
in {
|
||||
environment.systemPackages = with pkgs; [ pkgs.cryptsetup cb-mount cb-sync cb-unmount ];
|
||||
environment.systemPackages = [ cb-mount cb-unmount ];
|
||||
}
|
||||
|
@@ -27,11 +27,19 @@
|
||||
KERNEL=="sd?[0-9]", ENV{ID_MODEL}=="ST1000DM003-1SB102", ACTION=="add", RUN+="${pkgs.hdparm}/sbin/hdparm -S 24 /dev/%k"
|
||||
'';
|
||||
|
||||
services.borgbackup.repos.clerie-backup = {
|
||||
path = "/mnt/palladium/clerie-backup";
|
||||
authorizedKeysAppendOnly = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFyk716RnbenPMkhLolyIkU8ywUSg8x7hjsXFFQoJx4I root@clerie-backup"
|
||||
];
|
||||
services.borgbackup.repos = {
|
||||
clerie-backup = {
|
||||
path = "/mnt/palladium/clerie-backup";
|
||||
authorizedKeysAppendOnly = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFyk716RnbenPMkhLolyIkU8ywUSg8x7hjsXFFQoJx4I root@clerie-backup"
|
||||
];
|
||||
};
|
||||
external-drive = {
|
||||
path = "/mnt/external-drive/clerie-backup";
|
||||
authorizedKeysAppendOnly = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPuh74Esdp8JPgIZzM372DaCwtAl2QNtRratnIFG0NRB root@clerie-backup"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
clerie.monitoring = {
|
||||
|
Reference in New Issue
Block a user