No description
LICENSE | ||
proxmox-snapshot-rotation.sh | ||
README.md |
The script does the following:
- Comprehensive Logging System:
- Dedicated log directory and rotation
- Configurable log file size limits
- Different log levels (INFO, WARN, ERROR)
- Verbose mode option
- Log rotation when size limit is reached
- Robust Error Handling:
- Error codes for different failure scenarios
- Detailed error messages with timestamps
- Temporary file handling for error capture
- Proper cleanup of temporary files
- Error handling for all critical operations
- Process Management:
- Lock file mechanism to prevent multiple instances
- Proper cleanup of lock file using trap
- Stale lock detection and cleanup
- Input Validation:
- Parameter validation for numeric inputs
- Better argument parsing
- Clear help message with usage examples
- Safety Features:
- Separate functions for snapshot creation and deletion
- Better status checking and error reporting
- Verbose logging option for debugging
- Dry-run mode improvements
- Code Organization:
- Modular function design
- Clear separation of concerns
- Constants and configuration at the top
- Main function to orchestrate operations
- Better variable naming and scope management
To use the script:
- Save it to a location like
/usr/local/sbin/proxmox-snapshot-rotation.sh
- Make it executable:
chmod +x /usr/local/sbin/proxmox-snapshot-rotation.sh
- Create the log directory:
mkdir -p /var/log/proxmox-snapshots
You can run it with various options:
# Normal run
./proxmox-snapshot-rotation.sh
# Dry run with verbose output
./proxmox-snapshot-rotation.sh --dry-run --verbose
# Keep more snapshots and longer retention
./proxmox-snapshot-rotation.sh --keep 48 --retain-days 14
The script will create detailed logs in /var/log/proxmox-snapshots/
and handle various error conditions gracefully.