Skip to content

Commit b6d73c5

Browse files
committed
hosts(lt-hp-omen): make backup script easily rerunnable
1 parent 8a2a32a commit b6d73c5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hosts/lt-hp-omen/backup.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ let
33
backupScript = pkgs.writeShellScriptBin "backup" ''
44
set -x
55
DATE=$(date "+%Y%m%d")
6-
sudo btrfs subvol snapshot -r /mnt/root/home /mnt/root/home-$DATE
7-
sudo btrfs subvol snapshot -r /mnt/root/persistent /mnt/root/persistent-$DATE
6+
if [ ! -d "/mnt/root/home-$DATE" ]; then
7+
sudo btrfs subvol snapshot -r /mnt/root/home /mnt/root/home-$DATE
8+
fi
9+
if [ ! -d "/mnt/root/persistent-$DATE" ]; then
10+
sudo btrfs subvol snapshot -r /mnt/root/persistent /mnt/root/persistent-$DATE
11+
fi
812
sudo btrfs send /mnt/root/home-$DATE | pv | ssh lt-home-vm.lantian.pub "btrfs receive /mnt/storage/backups"
913
sudo btrfs send /mnt/root/persistent-$DATE | pv | ssh lt-home-vm.lantian.pub "btrfs receive /mnt/storage/backups"
1014
'';

0 commit comments

Comments
 (0)