How best backup docker containers including postgre db

I have some VPS servers in the cloud. I backup all of them except one. The one not backed up has an application on it that is installed in Docker. I am familiar with how to backup docker containers but this one also has a postgre db. My question is how I best backup the application containers including the db.
I run Ubuntu 22.04

Regards
Anders, a 70 y.o self taught nerd

Welcome to the forum!

You can either enable PostgreSQL write ahead logs, set up a persistent volume for PG Data and then just back up via the file system (a normal rsync will do), or you can have a separate script or something that runs pg_dumpall, or just pg_dump on the specific DB you need for your program.

Given that PG will be running inside Docker, if you don’t port-forward it to a host port, you’ll have to run the script inside docker and then back up the resulting dump via the file system (again, rsync will do).

A nice technique in Docker is that you can schedule your backup to run in an ephemeral container. To copy files you can use ‘volumes from’ to mount the volumes from that you want to copy in your backup container.

So cron initiates docker run on schedule, the container is created, runs its backup job and then exits when finished, and the container is destroyed.

In the case of what @ThatGuyB suggests above, you could run your pg_dump command in an emphemeral container on the same docker network as your PG database container without needing to expose your PG container via a host port.