diff options
Diffstat (limited to 'dotfiles/system/.local/bin/zfssnapshot')
| -rwxr-xr-x | dotfiles/system/.local/bin/zfssnapshot | 21 |
1 files changed, 14 insertions, 7 deletions
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 |
