diff options
Diffstat (limited to 'dotfiles/system/.local')
| -rwxr-xr-x | dotfiles/system/.local/bin/zfsrollback | 18 | ||||
| -rwxr-xr-x | dotfiles/system/.local/bin/zfssnapshot | 21 |
2 files changed, 32 insertions, 7 deletions
diff --git a/dotfiles/system/.local/bin/zfsrollback b/dotfiles/system/.local/bin/zfsrollback index a03cd57..6e727e2 100755 --- a/dotfiles/system/.local/bin/zfsrollback +++ b/dotfiles/system/.local/bin/zfsrollback @@ -110,6 +110,16 @@ echo "════════════════════════ echo " ⚠️ WARNING ⚠️" echo "═══════════════════════════════════════════════════════════════════" echo "" + +# Special warning for genesis rollback +if [[ "$snap_name" == "genesis" ]]; then + echo " 🚨 GENESIS ROLLBACK DETECTED 🚨" + echo "" + echo " Rolling back to genesis will destroy ALL changes since installation!" + echo " This includes all packages installed, configurations, and user data." + echo "" +fi + echo "You are about to roll back to snapshot: @${snap_name}" echo "" echo "The following datasets will be rolled back:" @@ -160,6 +170,14 @@ done echo "" if [ $failed -eq 0 ]; then echo "Rollback complete." + + # Update GRUB boot menu if grub-zfs-snap is available + # (destroyed snapshots need to be removed from menu) + if command -v grub-zfs-snap &> /dev/null; then + echo "" + echo "Updating GRUB boot menu..." + grub-zfs-snap + fi else echo "Rollback completed with $failed failure(s)" exit 1 diff --git a/dotfiles/system/.local/bin/zfssnapshot b/dotfiles/system/.local/bin/zfssnapshot index b715722..1fa7e3b 100755 --- a/dotfiles/system/.local/bin/zfssnapshot +++ b/dotfiles/system/.local/bin/zfssnapshot @@ -13,9 +13,9 @@ Create a ZFS snapshot across all datasets. -h display this help and exit DESCRIPTION short description for the snapshot (optional, will prompt if omitted) -Snapshot names are formatted as: YYYY-MM-DD-description +Snapshot names are formatted as: YYYY-MM-DD_HH-MM-SS_description Only alphanumeric characters, hyphens, and underscores are allowed in descriptions. -Spaces are converted to hyphens automatically. +Spaces are converted to underscores automatically. Examples: ${0##*/} before-upgrade @@ -63,8 +63,8 @@ else fi fi -# Sanitize description: convert spaces to hyphens, lowercase -description=$(echo "$description" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') +# Sanitize description: convert spaces to underscores, lowercase +description=$(echo "$description" | tr '[:upper:]' '[:lower:]' | tr ' ' '_') # Validate description: only allow alphanumeric, hyphens, underscores if [[ ! "$description" =~ ^[a-z0-9_-]+$ ]]; then @@ -74,9 +74,9 @@ if [[ ! "$description" =~ ^[a-z0-9_-]+$ ]]; then exit 1 fi -# Create snapshot name with date prefix -date_prefix=$(date +%Y-%m-%d) -snapshot_name="${date_prefix}-${description}" +# Create snapshot name with timestamp prefix (matches pre-pacman format) +timestamp=$(date +%Y-%m-%d_%H-%M-%S) +snapshot_name="${timestamp}_${description}" # Get all pools pools=$(zpool list -H -o name) @@ -101,3 +101,10 @@ done echo "" echo "Snapshot complete. Verify with: zfs list -t snapshot | grep $snapshot_name" + +# Update GRUB boot menu if grub-zfs-snap is available +if command -v grub-zfs-snap &> /dev/null; then + echo "" + echo "Updating GRUB boot menu..." + grub-zfs-snap +fi |
