Are there any cons in backup the entire container with gitea? reddit / selfhosted ---------------------------------------------------------------------- mavilesOficial · 2023-10-12 17:58 Hi, i self host a gitea in my raspberry pi cluster, i've deployed in a docker container using a docker compose running in the machine. My backups consists to a bash script that literaly get the container id, enter on it, and execute the command, "gitea dump > file" to backup, that i save in my NAS. I was thinking, since i have no docker volumes, why no simply make a docker commit (to generate a image from a running container) and save the backup image in some local image repo? Are there any cons on doing it? I was thinking because would be really simple to restore in case of any problem. ---------------------------------------------------------------------- vivekkhera · 2023-10-12 18:17 How do you restore only one git repo you accidentally messed up? ---------------------------------------------------------------------- lilolalu · 2023-10-12 18:55 I don't understand your question, what you are saying is that you have no seperation between persistent and temporary data? Like the most important conceptual mechanism about containers? I have my docker-compose files and the persistent data in a directory which I frequently back up. When the container images themself get damaged, I just restore this directory and start the containers again, they pull their images and access their persistent storage. If you have'nt done this yet, I think you should spent the time to do it... ---------------------------------------------------------------------- mavilesOficial · 2023-10-12 19:06 Basically yes, i have no separation between persistent and temporary data, no volumes at all. so the backups are done entering in the running container and copying the files. i could mount volumes, and zip the files too, I could do that. But, why not just make a frequent docker commit, and save the running image? If i need restore just a docker load and (i think) everything works. I was just thinking, why not? i mean, are there any downside on doing this? ---------------------------------------------------------------------- lilolalu · 2023-10-12 19:11 I still don't understand your use case. If you are storing a database in your MariaDB image and have no persistent storage defined, next time you do a "docker pull" to get an update of MariaDB, all your data is gone... That's not how containers are supposed to work, one of the main advantages is to seperate the data part from the software part so you can update the software frequently... ---------------------------------------------------------------------- Jaska001 · 2023-10-12 19:13 I was actually going to try this gitea backup approach. Stopping every container except gitea, Add, commit, push. Start everything back up. Though the performance doing this can be horrible and bloat the gitea db. ---------------------------------------------------------------------- lilolalu · 2023-10-12 19:14 https://docs.docker.com/engine/reference/commandline/commit/ ---------------------------------------------------------------------- thekrautboy · 2023-10-12 19:16 What the fuck kind of Frankensteins Monster setup is this?! *smh* ---------------------------------------------------------------------- mavilesOficial · 2023-10-12 19:26 Well pointed, "By default, the container being committed and its processes will be paused while the image is committed. This reduces the likelihood of encountering data corruption during the process of creating the commit. If this behavior is undesired, set the --pause option to false." I didn´t test, but i think there are a chance of corruption in this process, make sense for me to not use so. ---------------------------------------------------------------------- lilolalu · 2023-10-12 19:34 "docker commit" is something that you are not supposed to use. As the documentation states, there are scenarios where it's useful while you are manually debugging a container and want to keep that changes. Generally speaking an image should be built from a Dockerfile, without manual interaction and the need for "docker commit" ... Also you cannot commit to dockerhub image of MariaDB, only to your own containers / registry. If you are pulling an "official image" and then just keeping it locally, you will not receive any updates for the original container. So, I am still not sure but I think it might be that you haven't really understood the underlying concept of how to properly use containers.... https://docs.docker.com/storage/ ---------------------------------------------------------------------- nairou · 2023-10-12 19:51 1. Move your gitea data (default `/data` directory within the container) to a separate directory on the machine, outside of docker. 2. Map that directory as a volume for gitea in your docker compose config, as [per the instructions](https://docs.gitea.com/next/installation/install-with- docker). 3. Backup just that directory, not the docker container. 4. Never edit a docker container. ---------------------------------------------------------------------- atheken · 2023-10-12 20:55 If the container crashes between snapshots, you lose that time frame of data. If you use a volume, all the data is persisted on a disk outside of a container and you can restart it without any data loss. You can more easily automate filesystem backups using rsync or zfs dumps, for example. Including doing periodic snapshots. You should use volumes for persisting data, I've been using docker for 10+ years and I can't think of a single time I've taken an image dump or committed it in the manner you're describing. It's just not done. ---------------------------------------------------------------------- Infamous-Currency35 · 2023-10-12 21:43 First deploy it in a proper way (with volumes) and then just copy the folder. Stop the Container before you backup if youre feeling extra fancy. ---------------------------------------------------------------------- Zadok24 · 2023-10-12 22:13 Was ---------------------------------------------------------------------- Micex · 2023-10-12 23:35 Seems like you are not using the major advantage of containers. Taking snapshots limits you to have the same hardware configuration during restores. Do you have an automated tests for these snapshots? Else the snapshots are useless in the long run. ---------------------------------------------------------------------- TheRealSeeThruHead · 2023-10-13 04:27 This is probably fine. Tho not really in the spirit of docker lol. An image is just a snapshot of a systems state that you want to use as a starting point. So bundling the state of your gitea into an image is perfectly valid. ---------------------------------------------------------------------- HearthCore · 2023-10-13 05:46 Why not just backup the whole docker VM? ---------------------------------------------------------------------- VVaterTrooper · 2023-10-14 18:51 Ooh fancy!