docker-volume-backup/README.md

67 lines
2.1 KiB
Markdown
Raw Normal View History

2023-11-16 17:31:44 +01:00
# Backup Docker Volumes to Local
2023-11-16 17:32:30 +01:00
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](./LICENSE.txt)
2020-10-11 18:39:06 +02:00
2020-12-26 16:31:47 +01:00
## goal
2020-10-12 14:50:17 +02:00
This script backups all docker-volumes with the help of rsync.
2020-12-26 16:31:47 +01:00
## scheme
It is part of the following scheme:
![backup scheme](https://www.veen.world/wp-content/uploads/2020/12/server-backup-768x567.jpg)
Further information you will find [in this blog post](https://www.veen.world/2020/12/26/how-i-backup-dedicated-root-servers/).
## Backup all volumes
2020-10-12 14:50:17 +02:00
Execute:
2020-10-12 14:51:09 +02:00
2020-10-12 14:52:00 +02:00
```bash
2023-11-16 23:02:09 +01:00
./backup-docker-to-local.sh
2020-10-12 14:52:00 +02:00
```
2020-10-12 14:50:17 +02:00
2022-02-12 13:20:46 +01:00
## Recover
2022-02-12 14:05:54 +01:00
### database
2022-02-12 13:20:46 +01:00
```bash
docker exec -i mysql_container mysql -uroot -psecret database < db.sql
```
2022-02-12 14:05:54 +01:00
### volume
2021-08-19 13:09:44 +02:00
Execute:
```bash
2023-11-16 23:02:09 +01:00
bash ./recover-docker-from-local.sh "{{volume_name}}" "$(sha256sum /etc/machine-id | head -c 64)" "{{version_to_recover}}"
2021-08-19 13:09:44 +02:00
```
2022-02-12 13:20:46 +01:00
### Database
2020-12-27 10:12:47 +01:00
## Debug
To checkout what's going on in the mount container type in the following command:
```bash
docker run -it --entrypoint /bin/sh --rm --volumes-from {{container_name}} -v /Backups/:/Backups/ kevinveenbirkenbach/alpine-rsync
```
2020-10-12 14:50:17 +02:00
## Setup
Install pandas
2023-09-02 16:56:34 +02:00
## Author
2020-12-28 13:34:35 +01:00
2023-09-02 16:56:34 +02:00
Kevin Veen-Birkenbach
- 📧 Email: [kevin@veen.world](mailto:kevin@veen.world)
- 🌍 Website: [https://www.veen.world/](https://www.veen.world/)
## License
This project is licensed under the GNU Affero General Public License v3.0. The full license text is available in the `LICENSE` file of this repository.
2022-01-23 13:01:49 +01:00
2020-10-12 14:50:17 +02:00
## More information
- https://docs.docker.com/storage/volumes/
2020-12-28 13:34:35 +01:00
- https://blog.ssdnodes.com/blog/docker-backup-volumes/
- https://www.baculasystems.com/blog/docker-backup-containers/
- https://gist.github.com/spalladino/6d981f7b33f6e0afe6bb
2021-11-11 13:33:14 +01:00
- https://stackoverflow.com/questions/26331651/how-can-i-backup-a-docker-container-with-its-data-volumes
- https://netfuture.ch/2013/08/simple-versioned-timemachine-like-backup-using-rsync/
2022-01-23 13:01:49 +01:00
- https://zwischenzugs.com/2016/08/29/bash-to-python-converter/
2022-02-12 10:17:48 +01:00
- https://en.wikipedia.org/wiki/Incremental_backup#Incremental
- https://unix.stackexchange.com/questions/567837/linux-backup-utility-for-incremental-backups
- https://chat.openai.com/share/6d10f143-3f7c-4feb-8ae9-5644c3433a65