Exporting database through CLI (wp db export)


#1

I am attempting to export a site’s database through command line (for practice; I know this can be done via UIs). The steps I am taking:

  1. Right-click on site > “Open Site SSH”
  2. Run command: wp db export

I do receive a success message:

Success: Exported to 'local-2019-01-31-e26d535.sql'.

But—I can’t seem to locate this file. If I right-click on the site > “Reveal in Finder,” the .sql file isn’t placed in the /app/public or /app/sql folders, and I can’t seem to scp the file out of the container.

(Similarly, if I wanted to import a .sql file this way [wp db import], where would I place it?)

Thanks!


#2

Hey @AdamCap

You’re pretty close. After ssh'ing into the site, change to the webroot, and then export the db. So something like this:

  1. Right-click on site > “Open Site SSH”
  2. cd /app/public
  3. Run command: wp db export

This should export it into the public directory within the file explorer.

The reason for this is that the public folder is the one that is mounted into the site container, so the workflow that you were doing was essentially writing the db dump to a location inside of the container.

Hope that helps, and let me know if you have any other questions!

– Ben


closed #3

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.