Blog by Daniel Hauck. Sysadmin, Developer, Blogger.

TAG: mysql

PHP / Symfony Development Environment with Vagrant and Ansible – BONUS: MySQL

As I have received multiple requests now, I decided to make a little bonus for you 😉

It seems like a lot of you prefering mysql over postgresql. I don’t understand why, but that’s another topic 😉

You can do it!

Actually it ain’t that hard. But let’s go through it, step by step.

First, as usual, create your role:

We will reuse our apps config from the postgres database here, so nothing to change in case of the group_vars/all file.

Now it’s time to install the mysql server itself, therefore create a main.yml as usual:

As with postgres, to create databases and users, we need to install the python mysql binding, let’s to it.

Last but not least we will finally create our users and their databases:

Test it!

Get rid of the postgres role in provisioning/playbook.yml and replace it with

Now run your provisiong again, and you are ready to use mysql.

Ain’t that easy? See you next time!

Simple WordPress Bash Backup Script

Hey Guys,

I needed to do some backups of multiple wordpress sites, so I decided to write a backup script especially for wordpress.

All you need is to call the script with two parametes, the first is the folder where your wordpress instance is installed, in my case /var/www/
The second is the folder where to backup it.

So for example:
./backup_wordpress /var/www/ /tmp/backup/

That’s all, the script figures out how to connect to the database, creates a gzipped dump with timestamp, and creates a tar archive also with a timestamp.

You’ll find it in your specified folder under wp and db.

That’s it, have fun.

Quick and dirty MySQL Backup

When you just need a simple backup of all your databases, this three lines do the job for you.

Just save it to a file and run it as a cron every night
00 01 * * * /srv/scripts/mysql_backup
and you get a zipped dump of every database with a timestamp.

It is easy extendable, if you want to exclude a database just write it into the grep regex
grep -Ev "(information_schema|performance_schema|another_database)"

Have fun! 🙂

There are no more results.