From 9eaef445af0bfa0a4b6cf064230110a32ff28dc9 Mon Sep 17 00:00:00 2001 From: kebler Date: Tue, 7 Feb 2023 09:31:25 -0800 Subject: [PATCH] added beginning of btrfs module --- modules/btrfs.mod | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 modules/btrfs.mod diff --git a/modules/btrfs.mod b/modules/btrfs.mod new file mode 100644 index 0000000..e85b5c4 --- /dev/null +++ b/modules/btrfs.mod @@ -0,0 +1,32 @@ +#!/bin/bash +make_subvol() { + local usesudo + local uid + local gid + [[ $EUID -ne 0 ]] && usesudo=sudo + uid=${2:-$USER} + gid=${3:-$uid} + echo $usesudo btrfs subvolume create $1 + $usesudo btrfs subvolume create $1 + echo $usesudo chown $uid:$gid $1 + $usesudo chown $uid:$gid $1 +} + +make_base_subvols() { + svols="shell admin opt data docker images temp" + BTRFSDATAROOT=${BTRFSDATAROOT:-/mnt/data} + # cd $BTRFSDATAROOT || exit + for svol in $svols; do + make_subvol $BTRFSDATAROOT/$svol $@ + done +} + +#ssudo mount -o subvol=opt /dev/sda4 /test + +alias btvl="sudo btrfs subvolume list" + +# ALL ALL = (root) NOPASSWD:/bin/btrfs + +# btrfs send rootfs-nadal-$(date +"%d-%m-%Y") | btrfs receive /backup/images/snaps/rootfs +# btrfs subvolume snapshot -r / /backup/rootfs-nadal-$(date +"%d-%m-%Y") +# tar -cvpzf /backup/images/nadal-fs.tar.gz --one-file-system /