]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
pakfire: Create snapshots when performing core updates SNAPSHOTS
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 7 Jul 2025 07:45:37 +0000 (09:45 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Mon, 7 Jul 2025 07:45:37 +0000 (09:45 +0200)
Automatically create snapshots on systems which are using BTRFS on their
root devices.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
src/pakfire/lib/functions.pl

index e2c6463132517ad44e501fb9c880c9f6bfe000fd..1169cf10ff392114f6b5a31a52a08cd2c6ea5b7e 100644 (file)
@@ -21,6 +21,7 @@
 
 require "/opt/pakfire/etc/pakfire.conf";
 require "/var/ipfire/general-functions.pl";
+require "${General::swroot}/filesystem-functions.pl";
 
 use File::Basename;
 use File::Copy;
@@ -850,6 +851,20 @@ sub upgradecore {
        
        foreach $release (@seq) {
                chomp($release);
+
+               # Create a snapshot on systems with BTRFS on root.
+               if (&Filesystem::is_btrfs("/")) {
+                       # Generate snapshot name.
+                       my $snapshotname = "auto-update-to-core-" . "$release";
+
+                       # Log a message.
+                       message("CORE UPGR: Creating automatic BTRFS snapshot (\"$snapshotname\")");
+
+                       # Create the snapshot.
+                       &Filesystem::btrfs_create_snapshot("$snapshotname");
+               }
+
+               # Install the core update.
                upgradepak("core-upgrade-$release");
        }