getflywheel / local-cli

CLI for Local, the #1 local WordPress development tool
https://localwp.com
35 stars 9 forks source link

Feature request: SQL export #7

Open jvdh opened 3 years ago

jvdh commented 3 years ago

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

mikeybinns commented 2 years ago

+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.

alexclst commented 2 years ago

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.