From: Stefan Schantl Date: Mon, 7 Jul 2025 07:45:37 +0000 (+0200) Subject: pakfire: Create snapshots when performing core updates X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2FSNAPSHOTS;p=people%2Fstevee%2Fipfire-2.x.git pakfire: Create snapshots when performing core updates Automatically create snapshots on systems which are using BTRFS on their root devices. Signed-off-by: Stefan Schantl --- diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index e2c646313..1169cf10f 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -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"); }