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

Time:02-03

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 --src=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.

CodePudding user response:

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 --src=/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 --src=./dumps/db.sql.gz

or

ddev import-db --src=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 --src=.tarballs/junk.sql
ddev import-db --src=.tarballs/junk.sql.gz
ddev import-db --target-db=newdb --src=.tarballs/db.sql.gz
ddev import-db --src=.tarballs/db.sql.bz2
ddev import-db --src=.tarballs/db.sql.xz
ddev import-db <db.sql
ddev import-db someproject <db.sql
gzip -dc db.sql.gz | ddev import-db

CodePudding user response:

This error message indicates that the file dumpfile.sql.gz could not be found. This could be due to the file not existing in the specified location, or the file not having the correct permissions to be accessed. Check the file path and permissions to ensure that the file can be accessed.

  1. Make sure the file is in the correct location and try running the command again
  2. Check the permissions
  • Related