btrfish/bootstrap.fish

38 lines
712 B
Fish
Executable File

#!/usr/bin/fish
set scriptdir (dirname (status --current-filename))
source $scriptdir/config.fish
source $scriptdir/utils.fish
if test -d $subvoldir
echo "Backup directory already exists, aborting..."
exit
end
echo "Creating subvolume directory..."
mkdir $subvoldir
echo "Creating initial snapshots..."
for pair in (get-subvol-mounts)
set subvol (get-subvol $pair)
set mount (get-mount $pair)
set safename (clean-name $subvol)
set safepath $subvoldir/$safename
sudo btrfs subvolume snapshot -r $mount $safepath
set snapshots $snapshots $safepath
end
echo "Syncing..."
sync
echo "Sending to target..."
for snapshot in $snapshots
sudo btrfs send $snapshot | receive-on-target
end
echo "Done!"