getflywheel/local-cli

Feature request: SQL export

Opened this issue · 2 comments

jvdh commented

For backup purposes I'd like to be able to export the database of a project,

+1 and I would like to add a couple things:

local-cli db export Exports the database to an sql file at a default location (possibly also set a destination as an argument.) (command syntax similar to WP-CLI)
local-cli db import database.sql Imports the database from an sql file export. (command syntax similar to WP-CLI)
local-cli db snapshot-save Save the database state to a fixed location, possibly give it an ID for multiple snapshots.
local-cli db snapshot-restore Restore the database state to the most recent snapshot, or to the snapshot ID if provided.

The snapshot feature would be great for automatic tests, as you could easily save a state before running your tests, then restore it back after the tests have run, without needing any kind of manual input.

I'm not sure what all this would add that the WP-CLI doesn't have already (wp db ...). Since there are ways to access the WP-CLI from the host shell (see #5 for some discussion), using that for functionality it provides is probably best. Now, grant you, the snapshot feature may still be worth looking at, as it isn't quite a direct duplicate of WP-CLI, and since Local already has its own backing up of the database at site stop.