No description
Find a file
2024-12-07 20:14:14 +05:30
LICENSE Initial commit 2024-12-07 20:12:08 +05:30
proxmox-snapshot-rotation.sh Add proxmox-snapshot-rotation.sh 2024-12-07 20:14:14 +05:30
README.md Update README.md 2024-12-07 20:13:25 +05:30

The script does the following:

  1. 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
  1. 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
  1. Process Management:
  • Lock file mechanism to prevent multiple instances
  • Proper cleanup of lock file using trap
  • Stale lock detection and cleanup
  1. Input Validation:
  • Parameter validation for numeric inputs
  • Better argument parsing
  • Clear help message with usage examples
  1. Safety Features:
  • Separate functions for snapshot creation and deletion
  • Better status checking and error reporting
  • Verbose logging option for debugging
  • Dry-run mode improvements
  1. 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:

  1. Save it to a location like /usr/local/sbin/proxmox-snapshot-rotation.sh
  2. Make it executable: chmod +x /usr/local/sbin/proxmox-snapshot-rotation.sh
  3. 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.