]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
filesystem-functions.pl: Add btrfs_create_snapshot() function
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 5 May 2024 15:00:00 +0000 (17:00 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 5 May 2024 15:00:00 +0000 (17:00 +0200)
This function can be used to very easily create a snapshot.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
config/cfgroot/filesystem-functions.pl

index 6b041bc177b1e59f6aded18e146a22092fb7a22d..19a0978ae8acc7d654d87e529ca2e9a6ae64fa17 100644 (file)
@@ -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.
 ##