If you did this you might not know about the Proxmox Helper Scripts: https://tteck.github.io/Proxmox/
It has a bunch of scripts to help setup and maintain containers. This use case should be covered by the "Proxmox VE LXC Updater" in "Proxmox VE tools" group.