Portainer can copy a stack to another environment in a few clicks. It is a nice feature and it also has a trap.
Open the stack and select Migrate this stack. Choose the destination environment, optionally give it a new name, and click Migrate. If you want to keep the original, use Duplicate on the same screen instead.
The docs say migrating does not relocate the content of any persistent volumes attached to the stack. The new stack starts with empty volumes. For a stateless web app that is fine. For a database it is not.
So I would move the data myself first. One way is to copy the volume content with a throwaway container and tar, or to restore from the app’s own backup on the new side.
docker run --rm -v myvolume:/data -v $(pwd):/backup alpine \
tar czf /backup/myvolume.tar.gz -C /data .
Caveat on the Kubernetes side: migrating a Docker stack to Kubernetes uses Kompose and the docs call it experimental. Do not use that on something you care about.
For databases I would stop the stack first, copy the volume, then start the migrated one. A copy of a running database can be inconsistent, and the docs do not promise anything about it. A backup made by the app itself is safer than a file copy.
Further reading: Migrate or duplicate a stack, On this site: in a Portainer stack, env_file stack.env is not the same as a .env file, On this site: turn on Re-pull image in a Portainer Git stack so updates really update