]> arthur.barton.de Git - ax-linux.git/blob - btrfs/mksnapshot/btrfs-mksnapshot-rootfs
Add btrfs-mksnapshot-rootfs script
[ax-linux.git] / btrfs / mksnapshot / btrfs-mksnapshot-rootfs
1 #!/bin/bash -e
2 #
3 # btrfs-mksnapshot-rootfs -- Make snapshots of root filesystems ("/")
4 # Copyright (c)2014 Alexander Barton (alex@barton.de)
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11
12 NAME=`basename "$0"`
13
14 function Usage()
15 {
16         echo "Usage: $NAME"; echo
17         exit 1
18 }
19
20 [ $# -eq 0 ] || Usage
21
22 if [ -n "`fgrep ' / btrfs ' /etc/fstab 2>/dev/null`" ]; then
23         if [ -x /usr/local/sbin/btrfs-mksnapshot ]; then
24                 /usr/local/sbin/btrfs-mksnapshot -1 / || exit 1
25         else
26                 echo "\"/usr/local/sbin/btrfs-mksnapshot\" not executable, snapshot creation skipped."
27         fi
28 else
29         echo "Root filesystem is not ot type \"btrfs\", snapshot creation skipped."
30 fi
31 exit 0