Tag Archives: database

OVH awesome database backups

Yesterday, I made a huge mistake while testing a new version of my RSS syndication application: I ran the installation script, which has the effect of (re)creating all the tables used by the application.

This has reminded me of 2 things:

  • an installation script should not wipe existing tables, at least not without warning the user
  • a backup strategy would not be the worse idea

But knowing that and having a solution to my current problem are two completely different things.

Fortunately, OVH (the hosting service I’m using) are awesome, and allow you to retrieve a backup of your database, either from yesterday or from last week.

To create a dump of your database, connect to your hosting with SSH, then enter the following command:

mysqldump --host=your_host --user=your_user --password=your_password --port=3307 your_bdd > mybackup.sql

Port 3307 is used for yesterday’s backup, port 3317 is for last week’s.

This will create a dump of your database in the file mybackup.sql. To import it back, enter:

cat mybackup.sql | mysql --host=your_host --user=your_user --password=your_password your_bdd

And voilà, your database is back to the state it was in yesterday.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

1x7d9oGVqGxFvJj9yHRADoV1C4NAdywGG

If you enjoyed reading this post, please consider tipping me using Bitcoin. Each post gets its own unique Bitcoin address so by tipping you're not only making my continued efforts possible but telling me what you liked.

Reset a Heroku database

I’m currently developing a Play! application, and I use Heroku to deploy and test it.

But sometimes when deploying it, the application crashes when trying to start up. What happens is that the database contains data that are in conflict with the new schema that I’ve deployed (eg. new required foreign keys that don’t have a value…).

To fix this, the easiest way I’ve found is to reset my Heroku database. When connected to Heroku (with the Heroku Toolbelt), just run

heroku pg

which will display the list of your databases, then run

heroku pg:reset HEROKU_DATABASE_SOMEBASE

which will reset your database HEROKU_DATABASE_SOMEBASE.

Then you can restart your application with

heroku restart

and everything should be working fine.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

16dVFMiAWZ8kFY4QqTQewTQsbJUqzhWtPa

If you enjoyed reading this post, please consider tipping me using Bitcoin. Each post gets its own unique Bitcoin address so by tipping you're not only making my continued efforts possible but telling me what you liked.