"pct listsnapshot" strange output

greg

Renowned Member
Apr 6, 2011
135
2
83
Greetings
I have a cleanup script based on "pct listsnapshot" which stopped working a while ago.
While running manually, I found this output:
Code:
`-> daily_20181123              2018-11-23 04:30:07     no-description
  `-> daily_20181124            2018-11-24 04:30:07     no-description
    `-> daily_20181125          2018-11-25 04:30:07     no-description
      `-> daily_20181126        2018-11-26 04:30:07     no-description

and then
Code:
Deep recursion on anonymous subroutine at /usr/share/perl5/PVE/GuestHelpers.pm line 165.

Is it on purpose that the output starts with this weird single quote? for some reason it seems to break sed & awk. Is it possible to have a more "flat" ouput?

Thanks in advance

Regards
 
Hi,
approximately how many snapshots do you have? Seems like the function in question should be refactored into a loop, to not be recursive.

Regarding the output, it's supposed to represent part of the arrow. You need to escape/quote that symbol before passing it to another command.

You can also use
Code:
pvesh get /nodes/<node>/lxc/<ID>/snapshot
instead. See man pvesh for the possible output formats and the --noborder option. Note that you'll need to sort them by snaptime though, and for containers with too many snapshots this might not work until that Deep recursion error is fixed.
 
Thanks for you answer :) I indeed have a huge amount of snapshots, since my script broke a while ago. This weekend I ended up with this:

Code:
pct listsnapshot $ctID| grep "daily_$year" 2>/dev/null | tr -cs '[[:digit:]]\n' ' ' |awk '{print $1}' > zfs_list_$ctID_$year.lst

(visually check the output file, then)

Code:
cat zfs_list_$ctID_$year.lst | xargs -n1 -I {} sh -c "echo -e \" \e[33mCT $ctID\e[39m : {} \"; pct unlock $ctID; pct delsnapshot $ctID daily_{} || true"

Not really clean but it's working for now.
I'll check the command you quoted, thanks a lot!

Regards
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!