shell-base/modules/btrfs.mod

33 lines
861 B
Bash

#!/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 /