-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Support for backing up docker bind mounts #4
Comments
Maybe it could work in the form of a command to launch before/after the backup? locations:
docker-postgres:
from: /srv/docker-postgres/data
to: storage
run_before: docker stop postgres
run_after: docker start postgres this way it isn't specific to docker, and works for other use cases? |
This WE I'll be thinking about some potential ways to backup docker volumes. I assume you mean volumes that are not mapped to the local file system :) Good suggestion! |
@EliotBerriot your proposed hook looks great for CLI support; docker, kubectl, service, systemctl, etc. would have basic support with this. Just as an FYI, referencing similar functionality in other provisioning apps can be helpful, e.g. https://github.com/ansible/ansible-modules-core/blob/devel/system/service.py to avoid common pitfalls with sleep/timeouts/status codes/etc. @cupcakearmy I primarily use local file system mounts (or NFS, etc.) and my concern is stopping apps to keep data integrity. Of course first-class support for docker volumes (and/or other management APIs) would be fantastic. A basic shell hook would go a long way to supporting more cases. |
It makes the tool way more flexible. I'll implement it as soon as I have time :) |
https://github.com/cupcakearmy/autorestic#before--after-hooks I still need to think about what the best way is to integrate docker volumes. Any suggestions are welcome :) |
# Backup
docker run --rm --volume my_volume_to_backup:/data -v $(pwd):/backup alpine tar cf /backup/backup.tar -C /data .
# Restore
docker run --rm --volume my_volume_to_backup:/data -v $(pwd):/backup alpine tar xf /backup/backup.tar -C /data This could be the way to go |
So, I tried a few things 1
This worked but it had the problem that docker will modify permissions and groups of the files -> no,no 2Then i tried to do the same thing bypassing the mounted volume permissions limitation with tar
This unfortunately did work but again the permissions were lost. My guess is that if tar does not find the user when decompressing it will replace it. Not sure.. 3
This approach works perfectly but it does not allow incremental updates as restic just sees the tarbal. It's not the best thing, but at least it guarantees that permissions are preserved 100% So I implemented version 3. Will be released soon :) |
It's done 🚀 docker volumes can now be backed up and restored with out needing them to be mounted to the host. https://github.com/cupcakearmy/autorestic/blob/master/README.md#-docker-volumes |
can i backup mounted volumes using autorestic in docker ? is this possible ? or does it need autorestic running outside of docker to execute commands to stop/start the container ? thanks for the awesome project @cupcakearmy ! |
@FarisZR you can do that exactly with the locations:
mydb-backup:
from: /home/user/postgres
hooks:
before:
- sudo docker stop my-db
after:
- sudo docker start my-db EDIT: a better option to avoid downtime might be not to stop the container at all and use locations:
mydb-backup:
from: /var/backups/postgres
hooks:
before:
- mkdir -p /var/backups/postgres
- sudo docker run my-db pg_dumpall > /var/backups/postgres/backup.sql
after:
- rm /var/backups/postgres/backup.sql |
The commands wouldn't work if autorestic is also running inside docker.
…-------- Original Message --------
On Jan. 17, 2022, 12:50 p.m., cupcakearmy/autorestic - reply+aipxadswhzassie3t7s4wsf76eoorevbnhhb7iivfu at reply.github.com wrote:
***@***.***(https://github.com/fariszr) you can do that exactly with the before and after hooks:
locations
:
mydb-backup
:
from
:
/home/user/postgres
hooks
:
before
:
-
sudo docker stop my-db
after
:
-
sudo docker start my-db
—
Reply to this email directly, [view it on GitHub](#4 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AIPXADRYXBMRRTTROB5JRPDUWPQ6RANCNFSM4JTJCB3A).
Triage notifications on the go with GitHub Mobile for [iOS](https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or [Android](https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
One of my primary backup use cases is stopping a container, backing up the bind mounted host folders, and starting the container again. It would be awesome if autorestic had this kind of functionality for locations.
The text was updated successfully, but these errors were encountered: