From 80f9f873253129ad660cbdc908d58b5079273d9c Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sun, 5 May 2024 17:00:00 +0200 Subject: [PATCH] filesystem-functions.pl: Add btrfs_create_snapshot() function This function can be used to very easily create a snapshot. Signed-off-by: Stefan Schantl --- config/cfgroot/filesystem-functions.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config/cfgroot/filesystem-functions.pl b/config/cfgroot/filesystem-functions.pl index 6b041bc17..19a0978ae 100644 --- a/config/cfgroot/filesystem-functions.pl +++ b/config/cfgroot/filesystem-functions.pl @@ -648,6 +648,22 @@ sub btrfs_get_subvolumes ($) { return %subvolumes; } +# +## Easy to use function to create a new snapshot with a given name. +# +sub btrfs_create_snapshot ($) { + my ($name) = @_; + + # Call the btrfs_subvolume_snapshot function and pass the name. + my $ret = &btrfs_subvolume_snapshot($name); + + # Return the return code if there was one. + return $ret if($ret); + + # Return nothing on success. + return; +} + # ## Private function to filter the output of btrfs_subvolume_list command. ## -- 2.39.5