How to use "ddev import-db" and specify the path/file to import

I started working with Docker and need to set-up a website project. I also need to import the database via command ddev import-db --file=dumpfile.sql.gz

but where do I need to put this dumpfile.sql.gz file? I tried putting it in root folder of project but after running the above mentioned command, I get this error:

Failed to import database db for webproject: Unable to validate import asset dumpfile.sql.gz: invalid asset: file not found 

Sorry if maybe I'm missing some key concept understanding about Docker and import of files, but I don't understand the issue and googling this error (even parts of the error) returns absolutely no troubleshooting results.

2

2 Answers

You don't have to know anything about docker to use ddev import-db, and there are many examples if you use ddev import-db -h.

ddev import-db runs on your workstation, not inside the container. And the file you want to import is also on your workstation.

But the important thing you're missing is that you need a path or relative path to the file. So if the file is in /tmp, it would be

ddev import-db --file=/tmp/db.sql.gz

If the file is in a relative directory to where you're running the command, for example, if it's in a directory named "dumps" that is a subdirectory of your current directory, then

ddev import-db --file=./dumps/db.sql.gz

or

ddev import-db --file=dumps/db.sql.gz

This is just all about giving the command a way to find the file.

Examples from ddev import-db -h:

Examples: ddev import-db ddev import-db --file=.tarballs/junk.sql ddev import-db --file=.tarballs/junk.sql.gz ddev import-db --database=newdb --file=.tarballs/db.sql.gz ddev import-db --file=.tarballs/db.sql.bz2 ddev import-db --file=.tarballs/db.sql.xz ddev import-db <db.sql ddev import-db someproject <db.sql gzip -dc db.sql.gz | ddev import-db 
2

In older ddev versions is "src" instead of "file". Thus, for instance in ddev 19.2:

ddev import-db --src=./dumpfile.sql.gz

2

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobm5rYmiFdISOoaawZaSkera%2FxGabnZ2mYrauvM6rq2ackmKur7CMrKeem5mbxm7Ax55kqZmknXqntcueZK2nXZ66sbvRrQ%3D%3D