btrfish/bootstrap.fish

39 lines
791 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 "Warning: backup directory already exists."
echo "Existing subvolumes won't be overwritten."
else
echo "Creating subvolume directory..."
mkdir $subvoldir
end
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
if not test -d $safepath
sudo btrfs subvolume snapshot -r $mount $safepath
set snapshots $snapshots $safepath
end
end
echo "Syncing..."
sync
echo "Sending to target..."
for snapshot in $snapshots
sudo btrfs send $snapshot | receive-on-target
end
echo "Done!"