greenhouse

kore

my public infrastructure monorepo

git clone [email protected]:kore.git

feat(nixos/feats/global): keep old root for 7 day

commitc2933b06b522a298249399b64d95f987c6fbd5ec
parent5153a34c50dd1b9c98be6687f24ab7b01c6c4ef9
authorlostduk <[email protected]>
date2026-03-02 17:13 +0000
nixos/features/global.nix20++++++++++++--------

1 file changed, -8/+12

nixos/features/global.nix

@@ -113,15 +113,19 @@         mount ${rootDevice} "$MNTPOINT"         trap 'umount "$MNTPOINT"' EXIT -        echo "Moving old root..."-        mv "$MNTPOINT/@" "$MNTPOINT/@_old"--        echo "Creating a blank root subvolume..."+        if [[ -e $MNTPOINT/@ ]]; then+          echo "Backing up root..."+          mkdir -p $MNTPOINT/old_roots+          mv "$MNTPOINT/@" "$MNTPOINT/old_roots/@_$(date "+%Y-%m-%-d_%H:%M:%S")"+        fi++        echo "Deleting 7+ days old roots..."+        find "$MNTPOINT/old_roots" -mindepth 1 -maxdepth 1 \+          -mtime +7 \+          -exec btrfs sub del -R {} +++        echo "Creating new root..."         btrfs sub cre "$MNTPOINT/@"--        echo "Cleaning old root..."-        btrfs sub del -R "$MNTPOINT/@_old"-        rm -rf "$MNTPOINT/@_old"       )     '';   in {