Corsinvest / cv4pve-autosnap

Automatic snapshot tool for Proxmox VE
https://www.corsinvest.it/cv4pve
GNU General Public License v3.0
413 stars 51 forks source link

cv4pve_autosnap has stopped cleaning up old snapshots #15

Closed codesmaker closed 5 years ago

codesmaker commented 5 years ago

Hi,

First of all, I would like to thank you guys for your work on this very useful script.

I've noticed recently that the "cv4pve_autosnap" has stopped removing old snapshots based on the "--keep" option. It seems that it has no effect.

Here is the command I'm running: `cv4pve-autosnap snap --vmid=514 --label='24hours' --keep=2

2019-09-02 23:26:11 DEBUG: cv4pve-autosnap 0.1.11 2019-09-02 23:26:11 DEBUG: Command line: snap --vmid=514 --label=24hours --keep=2 2019-09-02 23:26:11 DEBUG: ------------------------------------------------------------ 2019-09-02 23:26:11 DEBUG: CV4PVE_AUTOSNAP_PHASE: snap-job-start 2019-09-02 23:26:11 DEBUG: CV4PVE_AUTOSNAP_VMID: 514 2019-09-02 23:26:11 DEBUG: CV4PVE_AUTOSNAP_VMTECNOLOGY:
2019-09-02 23:26:11 DEBUG: CV4PVE_AUTOSNAP_LABEL: 24hours 2019-09-02 23:26:11 DEBUG: CV4PVE_AUTOSNAP_KEEP: 2 2019-09-02 23:26:11 DEBUG: CV4PVE_AUTOSNAP_VMSTATE: 0 2019-09-02 23:26:11 DEBUG: CV4PVE_AUTOSNAP_SNAP_NAME: - 2019-09-02 23:26:11 DEBUG: ------------------------------------------------------------ 2019-09-02 23:26:12 DEBUG: ------------------------------------------------------------ 2019-09-02 23:26:12 DEBUG: CV4PVE_AUTOSNAP_PHASE: snap-create-pre 2019-09-02 23:26:12 DEBUG: CV4PVE_AUTOSNAP_VMID: 514 2019-09-02 23:26:12 DEBUG: CV4PVE_AUTOSNAP_VMTECNOLOGY: qm 2019-09-02 23:26:12 DEBUG: CV4PVE_AUTOSNAP_LABEL: 24hours 2019-09-02 23:26:12 DEBUG: CV4PVE_AUTOSNAP_KEEP: 2 2019-09-02 23:26:12 DEBUG: CV4PVE_AUTOSNAP_VMSTATE: 0 2019-09-02 23:26:12 DEBUG: CV4PVE_AUTOSNAP_SNAP_NAME: auto24hours190902232611 2019-09-02 23:26:12 DEBUG: ------------------------------------------------------------ VM 514 - Creating snapshot auto24hours190902232611 2019-09-02 23:26:12 DEBUG: qm snapshot 514 auto24hours190902232611 -description 'cv4pve-autosnap' 2019-09-02 23:26:14 DEBUG: return 0 2019-09-02 23:26:14 DEBUG: ------------------------------------------------------------ 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_PHASE: snap-create-post 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_VMID: 514 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_VMTECNOLOGY: qm 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_LABEL: 24hours 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_KEEP: 2 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_VMSTATE: 0 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_SNAP_NAME: auto24hours190902232611 2019-09-02 23:26:14 DEBUG: ------------------------------------------------------------ 2019-09-02 23:26:14 DEBUG: ------------------------------------------------------------ 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_PHASE: snap-job-end 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_VMID: 0 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_VMTECNOLOGY:
2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_LABEL: 24hours 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_KEEP: 2 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_VMSTATE: 0 2019-09-02 23:26:14 DEBUG: CV4PVE_AUTOSNAP_SNAP_NAME: - 2019-09-02 23:26:14 DEBUG: ------------------------------------------------------------ 2019-09-02 23:26:14 DEBUG: Execution: 3 sec.`

It creates a new snapshot but it never deletes.

Thanks a lot for your help.

franklupo commented 5 years ago

Hi, the problem was that the Proxmox Ve developers change the output command. Use another version that uses the native APIs. It can be used externally and works on the whole clustrer.

Best regards

codesmaker commented 5 years ago

The script that uses the native API works now. Awesome job!

Since the new script needs a username and password to use the API, do you think it is possible to save the credentials in a file and pass it as an option to the script?

Also, what is the minimum role we can assign to the PVE user in order to be able to snapshot VMs?

codesmaker commented 5 years ago

Another issue is that the 'status' option works for some VMs but it doesn't for others. Here is the error message that I'm getting:

cv4pve-autosnap --host=192.168.50.100 --username='test@pve' --password='password' --vmid='518' status

System.IndexOutOfRangeException Index was outside the bounds of the array. at BetterConsoleTables.Table.ToString(Int32[] columnLengths) at Corsinvest.ProxmoxVE.AutoSnap.Commands.Status(String vmIdsOrNames, String label) in C:\Users\Daniele\source\repos\OpenSource\ProxmoxVE\cv4pve-autosnap\src\dotnet\Corsinvest.ProxmoxVE.AutoSnap\Commands.cs:line 68 at McMaster.Extensions.CommandLineUtils.CommandLineApplicationExtensions.<>c__DisplayClass9_0.b__0() at Corsinvest.ProxmoxVE.Api.Extension.Utils.Shell.ShellHelper.ExecuteConsoleApp(CommandLineApplication app, TextWriter stdOut, String[] args)

franklupo commented 5 years ago

Hi, You can send me a list of snapshots that the 518 vm?

Best regards

codesmaker commented 5 years ago

Hi Franklupo,

The "518" VM has no snapshots. I have another VM (519) which has one snapshot. When I try to get its status, I get the same error message. Please find attached a picture for the snapshot.

VM_519_snapshots

franklupo commented 5 years ago

Hi, I fixed the error. New version released during the day.

Best regards

franklupo commented 5 years ago

See new release 1,2.0

Best regards