I’ve setup a home server to be used only for containerised services with Podman. I’ve choosen Fedora Server 41, and I see the default partitioning is LVM XFS, not Btrfs is I was used to with Desktop edition. It works very well and I’d like to have a Backup or Snapshot (not sure which one I need) on an external drive just to have a quick way to restore my server in case it melt. What’s the best and easiest way to do that?
There is some documentation for LVM here: Use LVM to system-upgrade a Fedora Linux server with minimal downtime - Fedora Magazine
Snapshots are not backups. They just record the necessary information to access the data blocks in the disk at a given time, so you can go back to that version if something goes wrong afterwards. But if the physical disk is damaged, you will lose the original data and the snapshot won’t work.
You need to protect the content you want to preserve via backup, ideally in another disk, and in a different location.
I have a similar structure, all services are handled by containers. Volumes and databases are backed up daily and stored in a different drive. Additionally, I upload these backups to a cloud service, so if my house burns out, I still have my data.
That’s something I had no idea. And what backup software do you use? Rsync or something more structured?
In the article I linked earlier, partclone is being used to duplicate the OS when upgrading. I don’t use LVM (anymore), but I would think it should be a simple task to run partclone a second time and point it at a partition mounted from remote storage such as an external USB drive to make an actual backup in addition to the snapshot.
If your main objective is backing up containers, I would suggest to use podman tools to export the volumes and databases. You can then copy the .tar
and .sql
archives anywhere, using any tool.
Let’s assume your external drive is mounted here: /mnt/backup
Some examples below:
Backing up volumes:
podman volume export -o=/mnt/backup/<volume-name>.tar <volume name>
Restoring volumes:
podman volume import <volume-name> /mnt/backup/<volume-name>.tar
Backing up a mariadb database:
podman exec <container-name> sh -c 'exec mariadb-dump <database-name> -uroot -p"$MARIADB_ROOT_PASSWORD"' > /mnt/backup/<database-name>.sql
Restoring a mariadb database:
podman exec -i <container-name> sh -c 'exec mariadb -uroot -p"$MARIADB_ROOT_PASSWORD" <database-name>' < /mnt/backup/<database-name>.sql
Backing up a postgres database:
podman exec <container-name> sh -c 'exec pg_dumpall -c -U $POSTGRES_USER' > /mnt/backup/<database-name>.sql
Restoring a postgress database:
podman exec -i <container-name> sh -c 'exec psql -U $POSTGRES_USER -d <database-name>' < /mnt/backup/<database-name>.sql
Yes my intent is to only have containers on this server, and the firewalld configuration can be saved too. But I thought SELinux would complain after a restore, isn’t this an issue? For Volumes I mean.
I didn’t have issues restoring, and I did restore several times when playing with my server.
Podman takes care of selinux context.