2
votes

Starting to learn and understand phing.

I would like to export sql database using Phing. Is it possible?

Or is the best approach to write bash script to run it? How do you do this within a build.xml file?

1

1 Answers

2
votes

I found out from a book that the best means of doing this is with the exec task:

<?xml version="1.0" encoding="UTF-8"?>
  <project description="MyFooProject">
  <tstamp/>
  ...
 <target name="backup-db" description="Backup the database before upgrade.">
    <!-- execute external command mysqldump to backup database -->
        <exec command="${ext.mysqldump} --quick --password=${db.password} --user=${db.user} ${db.name} > ${site.name}.${environment}.sql"
            dir="${db.backup.dir}"
            escape="false" />
            <echo message="Database dumped ${db.backup.dir}/${site.name}.${environment}.sql" />
</target>
</project>
</xml>