From 893a49a3f3de1d0ef316bf77c0cc1bf9b7bf5ee3 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 2 Oct 2023 08:30:20 +0200 Subject: [PATCH] Add fsfreeze support for QEMU/KVM/Proxmox installations (#2781) * Add fsfreeze support for QEMU/KVM/Proxmox installations Add fsfreeze scripts which calls the new Supervisor API to freeze Home Assistant Core and add-ons which support the backup freeze scripts (`backup_pre` and `backup_post`). This allows to create safe snapshots with databases running. * Fix lint issues --- .../systemd/system/qemu-guest.service.d/haos.conf | 3 +++ .../rootfs-overlay/usr/libexec/haos-freeze-hook | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/system/qemu-guest.service.d/haos.conf create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/haos-freeze-hook diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/qemu-guest.service.d/haos.conf b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/qemu-guest.service.d/haos.conf new file mode 100644 index 000000000..7d92caf11 --- /dev/null +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/qemu-guest.service.d/haos.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/libexec/qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0 --fsfreeze-hook /usr/libexec/haos-freeze-hook diff --git a/buildroot-external/rootfs-overlay/usr/libexec/haos-freeze-hook b/buildroot-external/rootfs-overlay/usr/libexec/haos-freeze-hook new file mode 100755 index 000000000..f15d058fd --- /dev/null +++ b/buildroot-external/rootfs-overlay/usr/libexec/haos-freeze-hook @@ -0,0 +1,15 @@ +#!/bin/sh +set -e + +action="$1" + +if [ "${action}" = "freeze" ]; then + echo "File system freeze requested, freezing Home Assistant" + ha backups freeze +elif [ "${action}" = "thaw" ]; then + echo "File system thaw requested, thawing Home Assistant" + ha backups thaw +else + echo "Unknown action ${action}" +fi +