I'm trying to do a php script to backup my database. Here's what I've tried so far :
$command = "mysqldump -u [username] -p [password] [databasename] | gzip > db.sql.gz";
$this->output = system($command);
How do I get the password and username from databases.yml ?
How can I do a script that sends me the backup file, instead of saving it on the server (à la phpmyadmin) ?
You can create a symfony task. If you pass in an environment (i.e. dev, prod) or connection you get access to the Doctrine connection manager and create a connection. You can use that connection to make a database dump or get the connection details from the connection manager.
You can use the doctrine insert sql task as template for your task. I've done similar in the past.