-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Please provide documention on restoring a docker volume from a backup to avoid "volume [volume name] already exists but was not created by Docker Compose. Use external: true to use an existing volume" #10087
Comments
why would you not use |
Lets say you have 3 projects running with VCS and stuff and the If for whatever reason you have not moved or restored docker-compose environments, good for you - but it happens. So it would be kind to provide an easy fix for users that have to do it - without changing the previous docker-compose configuration. |
Your use case is obviously valid, but since Docker Compose does not manage volume backups and restore, you can't expect it magically discovers one of the existing volume is a good match to be used for your app. This is the reason |
Hence why I recommended to remove the warning altogether first in #9969.
I'm not sure why I would backup anything from the volume but the files itself. But to humor you, how would one create such a backup in an easy way, @ndeloof ? If you care to look at the official docker documentation you may find that they only tar the the files: https://docs.docker.com/storage/volumes/#back-up-restore-or-migrate-data-volumes |
No specific reason, just saying: if you want Compose to consider your restored backup as a "native" volume, you also need to restore metadata.
There's indeed no portable volume backup solution. The documented one is the "lowest denominator". I would expect some volume driver do offer some advanced features, typically backup/restore, but this isn't part of the API. So you'll hav no better choice but bring your own solution here |
Yep, I recommend as stated #9969 to remove the warning. This is still the easiest solution for all around. It's even the same behavior as in the old v1.x version - and you can add it back later when there is such a time that this feat (of restoring a backup with labels and stuff) is possible with as easy build-in solution |
The warning is here by intent, to help users who actually want to use a volume they created on their own, but don't know how to "force compose to use it". We can't just "adopt" a volume, with risk to eventually delete user's data. So you have two options:
|
In case someone needs to create a volume with corresponding labels, its working like that: docker volume create --name "foo_bar" --label "com.docker.compose.project=foo" --label "com.docker.compose.version=2.17.3" --label "com.docker.compose.volume=bar" |
I would suggest to avoid "hacking" into creating a compose equivalent volume. Better let compose create it.
such a compose file let you run |
Merci @ndeloof pour l'exemple et vive le breizcamp :) Just to fix a little your sample Mine :
and use "-T" to avoid "the input device is not a TTY" cat /tmp/backup.tgz | docker compose run -T restore-backup |
The solution I came across is:
|
I'm getting this warning because one of the volumes in my project was made with the older docker-compose pip package.
In my situation the volume was created by compose..... just by an older version or should |
@robkorv please use |
Thanks. Yeah... for some reason 3 of the 5 volumes did not have any labels. They were really old though, created around "2020-12-18T10:38:02+01:00".... while the two that are not getting the warning are much newer. Thankfully the volumes did not contain anything important in my case. So I deleted them and on the next up they were recreated with the correct labels and same owner as the working volumes. |
Description
Since #9969 was closed and is apparently as designed please provide documentation on how to restore a volume from a backup without setting
external
totrue
and avoid getting a warning/error forever.The text was updated successfully, but these errors were encountered: