Consistent backups of named docker volumes? reddit / selfhosted ---------------------------------------------------------------------- mcc0unt · 2023-10-10 21:22 Hello together, as the title says, I’m kind of confused how to describe actual backups of names docker volumes. As far as I understand, a container shouldn‘t be running (for consistent backups of databases e.g.), then you can create a tar backup of this volume (I managed it [using this command](https://github.com/junedkhatri31/docker-volume-snapshot) ). After that you can manually put it somewhere or save that file to an bind mount where another container has access (e.g. Duplicati) and sync that folder to somewhere else. That’s what I tried for now. So the question is: isn’t there a simpler or more automatic way to do that? I read about borg or restic, but I didn’t get the idea what these problems are trying to do. Background info: docker is running on a VPS Thanks in advance! ---------------------------------------------------------------------- thekrautboy · 2023-10-10 21:29 Docker volumes are nothing else than just folders and files. You can use whatever software you like to back them up. Databases are often finnicky and its good practice to back them up "the proper way". For almost every type of database (MySQL, Postgres, SQLite, etc) there is a client tool with which you can do a proper backup/dump of the database. In theory just stopping the db containers and copying all the files would work. But in reality, it doesnt work all the time. So depending on how important your db data is, do it properly, or not. Bord and restic are two backup tools, yes. Im not sure what your exact question is about them. You could also simply use the search function on this subreddit because this exact question is asked quite often and the answers are always the same. Also subs like /r/Docker are propably more fitting. ---------------------------------------------------------------------- mcc0unt · 2023-10-10 21:34 First of all, thanks for that quick response! Not sure why this is NSFW, but happens often for many users in all subs (well, seems for me). So you propose to backup my DB‘s with mysqldump (in my case) and to safe everything else directly from /var/lib/…? ---------------------------------------------------------------------- thekrautboy · 2023-10-10 21:39 > So you propose to backup my DB‘s with mysqldump (in my case) Thats the proper way to do it. > to safe everything else directly from /var/lib/…? I dont know what you have in /var/lib/... Containers are meant to be ephemeral. So you only need to backup the specific persistent data and the config of the container (ideally you would use Docker compose, so just backup the docker-compose.yml file). With that you can restore the entire app anywhere. > The question for borg/restic actually was, how they integrate into a docker-environment. Again, they dont? Why would they? Docker volumes are just folders and files. ---------------------------------------------------------------------- Minituff · 2023-10-10 22:26 Hi there! I actually had the same exact problem as you and I couldn't find a solution to \*safely\* backup my container volumes. So I built a containerized solution called [Nautical- Backup](https://github.com/Minituff/nautical-backup) that will shutdown your container and copy the mounted volumes of your choice to another location. If you have any questions, or want me to make any additions, let me know and I'd be happy to ---------------------------------------------------------------------- EndlessHiway · 2023-10-11 01:21 I just watched a great video about this. Here are the show notes you might find useful.[Back up docker and keep your data.](https://wiki.opensourceisawesome.com/books/updating-docker- containers/page/update-docker-keep-your-data-too) Also, [Back up Docker data and configs.](https://wiki.opensourceisawesome.com/books/backing-up- docker/page/backup-docker-data-and-configs) ---------------------------------------------------------------------- Johnny_Wallet · 2023-10-11 08:12 You can use [docker volume backup](https://github.com/offen/docker- volume-backup) container. It allows stopping container before back up its volume (volume is mounted to backup container), run pre and post backup commands and supports several online backends (though you can just use local storage for backups and upload the file to any backend e.g. rclone supports).