added beginning of btrfs module

master
Kebler Network System Administrator 2023-02-07 09:31:25 -08:00
parent fa65a9f4a4
commit 9eaef445af
1 changed files with 32 additions and 0 deletions

32
modules/btrfs.mod Normal file
View File

@ -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 /