diff --git a/README.md b/README.md index 4ef69fa..33761db 100644 --- a/README.md +++ b/README.md @@ -13,23 +13,25 @@ chmod +x /root/proxmox-autosnap/proxmox-autosnap.py ## Help -| Arguments | Required | Type | Default | Description | -|---------------------|----------|------|---------|------------------------------------------------------------------| -| vmid | yes | list | empty | Space separated list of CT/VM ID or `all` for all CT/VM in node. | -| snap | yes | bool | false | Create a snapshot but do not delete anything. | -| autosnap | no | bool | false | Create a snapshot and delete the old one. | -| keep | no | int | 30 | The number of snapshots which should will keep. | -| label | no | str | daily | One of `minute`, `hourly`, `daily`, `weekly`, `monthly`. | -| clean | no | bool | false | Delete all or selected autosnapshots. | -| exclude | no | list | empty | Space separated list of CT/VM ID to exclude from processing. | -| mute | no | bool | false | Output only errors. | -| running | no | bool | false | Run only on running vm, skip on stopped. | -| includevmstate | no | bool | false | Include the VM state in snapshots. | -| dryrun | no | bool | false | Do not create or delete snapshots, just print the commands. | -| date-iso-format | no | bool | false | Store snapshots in ISO 8601 format. | -| date-truenas-format | no | bool | false | Store snapshots in TrueNAS format. | -| sudo | no | bool | false | Launch commands through sudo. | -| zfs-send-to | no | str | empty | Send a copy of zfs subvolumes to another host via syncoid | +| Arguments | Required | Type | Default | Description | +|---------------------|----------|------|---------|---------------------------------------------------------------| +| vmid | no | list | empty | Space separated list of CT/VM IDs or `all`. | +| snap | no | bool | false | Create a snapshot but do not delete anything. | +| autosnap | no | bool | false | Create a snapshot and delete the old one. | +| keep | no | int | 30 | The number of snapshots which should will keep. | +| label | no | str | daily | One of `minute`, `hourly`, `daily`, `weekly`, `monthly`. | +| clean | no | bool | false | Delete all or selected autosnapshots. | +| exclude | no | list | empty | Space separated list of CT/VM IDs to exclude from processing. | +| mute | no | bool | false | Output only errors. | +| running | no | bool | false | Run only on running vm, skip on stopped. | +| includevmstate | no | bool | false | Include the VM state in snapshots. | +| dryrun | no | bool | false | Do not create or delete snapshots, just print the commands. | +| date-iso-format | no | bool | false | Store snapshots in ISO 8601 format. | +| date-truenas-format | no | bool | false | Store snapshots in TrueNAS format. | +| sudo | no | bool | false | Launch commands through sudo. | +| zfs-send-to | no | str | empty | Send a copy of zfs subvolumes to another host via syncoid | +| tags | no | list | empty | Space separated list of tags | +| exclude-tags | no | list | empty | Space separated list of tags to exclude | > proxmox-autosnap.py --help @@ -66,6 +68,11 @@ proxmox-autosnap.py --snap --vmid 100 --date-iso-format # Example autodaily20240212194857 # It is not necessary to specify the --date-truenas-format argument to delete snapshots proxmox-autosnap.py --snap --vmid 100 --date-truenas-format + +# Create a snapshot filtered by tags and exclude tags +# Tags are supported only in Proxmox version 7.3 and above +proxmox-autosnap.py --sudo --snap --tags snap --label hourly +proxmox-autosnap.py --sudo --snap --vmid all --label hourly --exclude-tags nosnap ``` ## SUDO @@ -75,7 +82,11 @@ In order to run with sudo argument, you must first create a user and specify min `cat /etc/sudoers.d/proxmox-backup` ```bash -proxmox-backup ALL=NOPASSWD: /usr/bin/cat /etc/pve/.vmlist, /usr/sbin/pct snapshot *, /usr/sbin/pct listsnapshot *, /usr/sbin/pct delsnapshot *, /usr/sbin/qm snapshot *, /usr/sbin/qm listsnapshot *, /usr/sbin/qm delsnapshot * +Cmnd_Alias VMLIST = /usr/bin/cat /etc/pve/.vmlist +Cmnd_Alias PCT = /usr/sbin/pct snapshot *, /usr/sbin/pct listsnapshot *, /usr/sbin/pct delsnapshot * +Cmnd_Alias QM = /usr/sbin/qm snapshot *, /usr/sbin/qm listsnapshot *, /usr/sbin/qm delsnapshot * +Cmnd_Alias PVESH = /usr/bin/pvesh get /cluster/resources --type vm --output-format json +proxmox-backup ALL=NOPASSWD: VMLIST,PCT,QM,PVESH ``` After that you can run the script with the argument