# PostgreSQL Backup and Restore module

**URL:** <https://forum.ansible.com/t/postgresql-backup-and-restore-module/17038>\
**Category:** Ansible Developer\
**Created:** [December 12, 2014, 5:52am UTC](https://forum.ansible.com/t/postgresql-backup-and-restore-module/17038 "2014-12-12T05:52:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bibhas\_Debnath](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Bibhas\_Debnath](https://forum.ansible.com/u/Bibhas_Debnath)\
**Post date:** [December 12, 2014, 5:52am UTC](https://forum.ansible.com/t/postgresql-backup-and-restore-module/17038/1 "2014-12-12T05:52:27Z")

</div>

While working on setting up our database with Ansible I felt the need of these 2 modules. As suggested by @abadger[1](https://github.com/ansible/ansible-modules-core/issues/474#issuecomment-66339825) I want to discuss if anybody thinks it’s worth it. For now I’m just using command module to run pg\_dump and pg\_restore. Postgres\_backup/restore modules can use these commands underneath with options -

1. database name
2. format(plain, custom)
3. destination file
4. owner
5. host

I can contribute in coding it. Just wanted some feedback.

Thanks.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 12, 2014, 1:51pm UTC](https://forum.ansible.com/t/postgresql-backup-and-restore-module/17038/2 "2014-12-12T13:51:08Z")

</div>

what about the ability to selectively restore a tablespace/db/table?

---

<div class="post-metadata">

**Author:** ![Bibhas\_Debnath](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Bibhas\_Debnath](https://forum.ansible.com/u/Bibhas_Debnath)\
**Post date:** [December 12, 2014, 4:21pm UTC](https://forum.ansible.com/t/postgresql-backup-and-restore-module/17038/3 "2014-12-12T16:21:14Z")

</div>

> what about the ability to selectively restore a tablespace/db/table?

Yes. It’s also possible to selectively backup and restore tables/namespace only. We can make it a part of the same module. If we use pg\_dump underneath, tables can be selected using wildcard too.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 15, 2014, 11:42am UTC](https://forum.ansible.com/t/postgresql-backup-and-restore-module/17038/4 "2014-12-15T11:42:42Z")

</div>

Depends how mainstream it would be, and how many people could use the implementation, about whether it’s a good fit for core, ultimately.

I am conceptually interested but normally would just shell out to postgresql commands, and generally we do push back on modules that are simple command wrappers.
