Portainer can back itself up, and I find that people skip it until the day they need it. It sits in the settings and takes a few seconds.
Open Settings, scroll down to Back up Portainer and click Download backup. You get a tar.gz file. Turn on Password protect first if you plan to keep the file somewhere shared, because it holds your users, registry credentials and Git credentials.
According to the docs the backup contains the Portainer database, stack files deployed through Portainer, users, teams, environments, registries and custom templates. Only admins can make one.
The caveat is the part people get wrong. It restores Portainer, not what Portainer manages. The docs say containers, images and volumes are not in it, and neither is the data in your bind mounts. So your Nextcloud files or your databases still need their own backup.
My habit would be simple: download a backup right before you update the container, and keep it off the machine that runs Portainer.
I would also keep the password for the backup somewhere other than the file itself. A password manager is the obvious place. A backup you cannot open is just a tar file taking up space, and you only find out during a restore.
Further reading: Back up Portainer, What does Portainer's backup include?, On this site: update Portainer by pulling the lts tag and recreating the container, On this site: you can only restore a Portainer backup on a fresh install, during setup