Skip to content

filipnet/proxmox-snapshot-report

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Proxmox Compatible LXC Supported VM Supported

Proxmox Snapshot Report

What is this?

Proxmox Snapshot Teaser

A Bash script for generating a periodical report of snapshots for Proxmox VMs and LXC containers. It scans all VMs and containers for snapshots, creates a report with details, and sends it via email if snapshots are found. The script works on both standalone Proxmox hosts and in Proxmox clusters. In a cluster, you only need to set up the script on one node, as it will collect all VMs and containers across the cluster.

Persistent snapshots can continuously grow, potentially impacting system performance and stability. This script helps prevent such issues by providing regular reports, making it easier to identify and clean up old or unnecessary snapshots.

Use Cases

  • Monitor snapshot usage in Proxmox environments
  • Automatically receive snapshot reports via email to avoid manual checks
  • Detect old or orphaned snapshots that should be cleaned up
  • Audit snapshot descriptions and creation dates for compliance and management
  • Prevent uncontrolled snapshot growth by providing regular reports and reminders for cleanup

Installation

Choose one of the following methods to install the script on your Proxmox host:

1. Manual Installation (recommended)

  1. Download the proxmox_snapshot_report.sh file from GitHub (e.g., using your browser).
  2. Copy the file to /usr/local/bin/:
    cp /path/to/proxmox_snapshot_report.sh /usr/local/bin/proxmox_snapshot_report.sh

2. Installation via wget

  1. Download the script directly:
    wget https://github.com/filipnet/proxmox-snapshot-report/raw/main/proxmox_snapshot_report.sh -O /usr/local/bin/proxmox_snapshot_report.sh

3. Installation via git

  1. Install git if not already present:
    apt update && apt install git
  2. Clone the repository:
    git clone https://github.com/filipnet/proxmox-snapshot-report.git
  3. Copy the script to /usr/local/bin/:
    cp proxmox-snapshot-report/proxmox_snapshot_report.sh /usr/local/bin/proxmox_snapshot_report.sh

Final Step (required)

Make the script executable:

chmod +x /usr/local/bin/proxmox_snapshot_report.sh

Update

To update the script, replace the file with the latest version.

⚠️ Note: Before updating, back up your configuration variables—either save them separately or rename the existing script.

Configuration

All configuration variables are located at the beginning of the script:

  • REPORT_EMAIL: Recipient address for the report
  • MIN_SNAPSHOT_AGE_DAYS: Minimum age (in days) of snapshots to include
  • INCLUDE_VM_SNAPSHOTS: "true" or "false" (as a string), whether to include VM snapshots
  • INCLUDE_LXC_SNAPSHOTS: "true" or "false" (as a string), whether to include LXC snapshots
  • MAIL_SUBJECT: Subject line of the report email
  • ENABLE_LOGGING: Enables console log output ("true"/"false" as a string, not 1/0)

Run the Script

Manual

To run the script manually, enter the following command on your Proxmox host:

/usr/local/bin/proxmox_snapshot_report.sh

The output will appear directly in the terminal. The script generates the snapshot report and sends it via email if configured.

Cronjob (recommended)

root@pve:~# crontab -e
no crontab for root - using an empty one

Select an editor. To change later, run 'select-editor'.

1. /bin/nano <---- easiest
2. /usr/bin/vim.basic
3. /usr/bin/vim.tiny

Choose 1-3 [1]: 1

For example, add the following line to receive the report every Monday at 7:00 AM:

0 7 * * 1 /usr/local/bin/proxmox_snapshot_report.sh > /dev/null 2>&1

Save the file. The cronjob will now run the script automatically at the specified time and send the report via email.

Note: Make sure that email sending is properly configured on your Proxmox host so that reports can be delivered.

Example command line output

Below is an example of the script's output as seen on the command line when executed manually:

root@pve:~# ./proxmox_snapshot_report.sh
[INFO] Creating snapshot report at /tmp/pve_snapshot_report.txt
[INFO] Scanning VM snapshots...
[INFO] Processing VM 112
[INFO] Processing VM 114
[INFO] Processing VM 113
[INFO] Scanning LXC snapshots via pct...
[INFO] Processing LXC 102
[INFO] Processing LXC 103
[INFO] Processing LXC 107
[INFO] Processing LXC 108
[INFO] Processing LXC 111
[INFO] Processing LXC 121
[INFO] Sending report to admin@example.tld

Example Email

Type  VMID  Snapshot Name  Snapshot Date        Description
LXC   111   Test           2025-07-05 07:52     This is a test for the notification script
VM    112   backup1        2025-07-07 22:30     Weekly backup before update

Security Notice

The script requires root privileges because it accesses all VMs and containers. Review the code before use and only run it on trusted systems.

⚠️ Note: Use this script at your own risk. The authors and contributors are not responsible for any damage, data loss, or issues resulting from its use. Always test scripts in a safe environment before deploying them in production.

Contribution

Contributions and improvements are welcome. Please submit pull requests or open issues for feature requests and bug reports.

License

This project is licensed under the BSD 3-Clause License. See the LICENSE for details.