Skip to content

Instantly share code, notes, and snippets.

@rponte
Created November 23, 2011 19:34
Show Gist options
  • Save rponte/1389656 to your computer and use it in GitHub Desktop.
Save rponte/1389656 to your computer and use it in GitHub Desktop.
setting password to run pg_restore and pg_dump with ant script
<exec failifexecutionfails="true" failonerror="true"
executable="${postgres.dir}/bin/pg_dump"
output="backup-ouput.txt">
<env key="PGPASSWORD" value="${postgres.password}" />
<arg value="-U" />
<arg value="${postgres.user}" />
<arg value="-h" />
<arg value="${postgres.host}" />
<arg value="-Fc" />
<arg value="--blobs" />
<arg value="-f" />
<arg value="${backup.db.file.path}" />
<arg value="mydb" />
</exec>
<available property="backup.file.present" file="${backup.db.file.path}"
type="file" description="Verificando se arquivo de backup do banco de dados foi criado corretamente." />
<fail unless="backup.file.present"
message="Erro ao tentar efetuar backup do banco de dados." />
<exec failifexecutionfails="true" failonerror="true"
executable="${postgres.dir}/bin/pg_restore"
output="restore-output.txt">
<env key="PGPASSWORD" value="${postgres.password}" />
<arg value="-U" />
<arg value="${postgres.user}" />
<arg value="-h" />
<arg value="${postgres.host}" />
<arg value="--dbname" />
<arg value="mydb" />
<arg value="--verbose" />
<arg value="${backup.db.file.path}" />
</exec>
@rodrigodealer
Copy link

:*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment