Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

ddev

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.

like image 630
Bernard Polman Avatar asked Oct 12 '25 11:10

Bernard Polman


1 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

From the docs:

  • import-db doc
  • Database management
like image 169
rfay Avatar answered Oct 14 '25 01:10

rfay