Kategorien
ANT Apache Deployment Linux MySQL Server Shell XML

ant task – mysqldump mit gzip

um mit ant einen gezipten mysqldump zu erstellen, gehe wie folgt vor

    <target name="tstamp" description="create timestamp for further usage">
        <echo message="create timestamp for further usage"/>
        <tstamp/>
    </target>

    <target name="mkdir" description="create backup directory">
        <echo message="create backup directory"/>
        <mkdir dir="${backups}"/>
    </target>

    <target name="dump" description="create db dump and gzip it - depends on tstamp, mkdir" depends="tstamp, mkdir">
        <echo message="create db dump and gzip it"/>
        <exec executable="bash" dir="${backups}">
            <arg value="-c"/>
            <arg line='"mysqldump ${db} -u${db_user} -p${db_pass} | gzip > ${backups}/${db}_${DSTAMP}_${TSTAMP}.sql.gz"'/>
        </exec>
    </target>