Use functions
This commit is contained in:
parent
a7bb5cfd85
commit
bd767dac81
|
@ -3,14 +3,18 @@
|
||||||
set scriptdir (dirname (status --current-filename))
|
set scriptdir (dirname (status --current-filename))
|
||||||
|
|
||||||
source $scriptdir/config.fish
|
source $scriptdir/config.fish
|
||||||
|
source $scriptdir/utils.fish
|
||||||
|
|
||||||
if test -d $subvoldir
|
if test -d $subvoldir
|
||||||
echo "Backup directory already exists, aborting..."
|
echo "Backup directory already exists, aborting..."
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
echo "Creating subvolume directory..."
|
||||||
mkdir $subvoldir
|
mkdir $subvoldir
|
||||||
|
|
||||||
for subvol in (eval $scriptdir/get-subvols.fish)
|
for subvol in (get-subvols)
|
||||||
|
set safename (clean-name $subvol)
|
||||||
|
echo "Creating initial snapshot for $subvol ($subvoldir/$safename)"
|
||||||
echo $subvol
|
echo $subvol
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/usr/bin/fish
|
|
||||||
sed 's/\//-/g'
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/usr/bin/fish
|
|
||||||
cat /etc/fstab | grep subvol | sed 's/.*subvol=//;s/)//;s/\t\| \|0//g'
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/fish
|
||||||
|
|
||||||
|
function get-subvols
|
||||||
|
cat /etc/fstab | grep subvol | sed 's/.*subvol=//;s/)//;s/\t\| \|0//g'
|
||||||
|
end
|
||||||
|
|
||||||
|
function clean-name
|
||||||
|
echo $argv | sed 's/\//-/g'
|
||||||
|
end
|
Loading…
Reference in New Issue