Access .SQL Database Files from remote

Bit of a long shot here - I’ve managed to kill a site and in the hope of getting it back to life quickly I’ve accepted that I would like to spin up a new droplet - the only thing I need is the latest version of the SQL Database so I lose as little data (if any) as possible.

Just wondering where I can find this. I still have SSH access.

The request is a bit nebulous as far as what “killing” the site entails and what the current setup looks like. If your WordPress install is not totally broken and wpcli is available, you can grab a copy of the database via SSH using wp db export (https://wp-cli.org/commands/db/export/). If you have cPanel/phpMyAdmin access, you can get a copy that way. Depending on the nature of the break, the database may not be in tact.

2 Likes

If with “killing” you didn’t mean destroying your droplet, you can grab your db with sequel pro (highly recommended).
I recommend you create a profile for your different environments, like development, staging and production.

If in doubt, these are the fields you need to fill in:

MySql Host -> IP of your droplet
Username -> site name as defined in wordpress_sites
password -> db password as defined in your vault
database -> depends, but I believe the last version of trellis uses the pattern sitename_enviroment (sitename as defined in wordpress_sites)

ssh host -> your ip again
ssh user -> root

Hope that helps.

2 Likes

I didn’t need this in this instance Bruno, but definitely very useful for the future and will no doubt revisit this - hopefully it comes in handy for others too :slight_smile: