Podman Container Backups

What are people using to backup podman containers?

I am running a F40 server in a home lab environment and hosting my own instance of Joplin for study notes, that I installed using cockpit.

Ideally would like to have a local backup to usb or replicate to an s3 bucket. Any suggestions would be appreciated.

I guess in your case, I would just use an Image like fedora:latest in a podman compose/Dockerfile and install Joplin and any other tools in the image . You would only need to back up your notes.

I’m sure there are better solutions than what I recommend.

Welcome to :fedora: !

Podman containers usually store their data in volumes. It is best practice to avoid storing state/data in the container itself because that makes image updates difficult. Usually creating backups of the volumes is enough, a container can easily be recreated using the same image and config. For recreating the container you might need backups of cockpit, but I never used cockpit so I am not sure.

With that in mind, here are some commands that can be used to create backups of the volumes:

Show all volumes

$ podman volume ls
DRIVER      VOLUME NAME
local       systemd-caddy
local       systemd-git-postgres
local       systemd-git-postgres-backup

Backup a volume

$ podman volume export systemd-caddy > caddy-backup.tar
$ ll -ah
-rw-r--r--. 1 core core 126K Jul  6 13:54 caddy-backup.tar

Restore a volume

$ cat caddy-backup.tar | podman volume import systemd-caddy -

Inspect a volume

$ podman volume inspect systemd-caddy
[
     {
          "Name": "systemd-caddy",
          "Driver": "local",
          "Mountpoint": "/var/home/core/.local/share/containers/storage/volumes/systemd-caddy/_data",
          "CreatedAt": "redacted",
          "Labels": {
               "backup": "true"
          },
          "Scope": "local",
          "Options": {},
          "MountCount": 0,
          "NeedsCopyUp": true,
          "LockNumber": 0
     }
]

As you can see the volume is just a normal directory stored in /var/home/[user]/.local/share/containers/storage/volumes/[volume name]/_data. Creating a backup of this directory is another option. Using a bind mount instead of a volume should also work, but then podman no longer handles the file permissions.

I am using restic to create backups of my container volumes. A script finds the volumes with a backup=true label and uploads them to blackblaze b2 (s3). The backup label is useful to avoid creating backups of cache / database volumes. Databases are backed-up by doing a pg_dump/mysqldump into another volume with a backup=true label (database backups can be inconsistent if backed-up directly). If you are interested in my setup I could share the script that I am using. I think it might be a bit overkill for your setup though, as you are just running a single container.


@brodomir would it be okay if I move this topic into ask fedora? This is a question and Ask gets a lot more visibility/answers than the water cooler.

1 Like

Of course move it , It’s only here because I was unsure where to post.

I’ll have a look into restic and see if I can get it working. Thank you for the information.

From The Water Cooler to Ask Fedora

Added backup, podman and removed off-topic