23 lines
486 B
Bash
23 lines
486 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -eo pipefail
|
||
|
|
||
|
if [[ -e restoration ]]; then
|
||
|
echo 'Error: an operation is already ongoing' >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
mkdir restoration
|
||
|
|
||
|
echo "restoring baks/epoch" >&2
|
||
|
sudo btrfs receive restoration -f baks/epoch
|
||
|
|
||
|
find baks -maxdepth 1 -type f | sort | head -n-1 | while read -r file; do
|
||
|
echo "restoring $file" >&2
|
||
|
mv restoration/{current,last}
|
||
|
sudo btrfs receive restoration -f "$file"
|
||
|
sudo btrfs subvol delete restoration/last
|
||
|
done
|
||
|
|
||
|
echo "restoration complete" >&2
|