]> arthur.barton.de Git - ax-linux.git/blobdiff - btrfs/mksnapshot/btrfs-mksnapshot-rootfs
Add btrfs-mksnapshot-rootfs script
[ax-linux.git] / btrfs / mksnapshot / btrfs-mksnapshot-rootfs
diff --git a/btrfs/mksnapshot/btrfs-mksnapshot-rootfs b/btrfs/mksnapshot/btrfs-mksnapshot-rootfs
new file mode 100755 (executable)
index 0000000..798e608
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash -e
+#
+# btrfs-mksnapshot-rootfs -- Make snapshots of root filesystems ("/")
+# Copyright (c)2014 Alexander Barton (alex@barton.de)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+
+NAME=`basename "$0"`
+
+function Usage()
+{
+       echo "Usage: $NAME"; echo
+       exit 1
+}
+
+[ $# -eq 0 ] || Usage
+
+if [ -n "`fgrep ' / btrfs ' /etc/fstab 2>/dev/null`" ]; then
+       if [ -x /usr/local/sbin/btrfs-mksnapshot ]; then
+               /usr/local/sbin/btrfs-mksnapshot -1 / || exit 1
+       else
+               echo "\"/usr/local/sbin/btrfs-mksnapshot\" not executable, snapshot creation skipped."
+       fi
+else
+       echo "Root filesystem is not ot type \"btrfs\", snapshot creation skipped."
+fi
+exit 0