# Ansible Database Backup [![Use community.postgresql.postgresql_db](https://docs.ansible.com/ansible/latest/collections/community/postgresql/postgresql_db_module.html#ansible-collections-community-postgresql-postgresql-db-module)](https://docs.ansible.com/ansible/latest/collections/community/postgresql/postgresql_db_module.html#ansible-collections-community-postgresql-postgresql-db-module) Backup database from remote postgresql for {{store}} days. ## Install ``` ansible-galaxy collection install community.postgresql ``` ## How to dump ``` ansible-playbook sd_pro_dump.yml -l sd-pgsql9 --extra-vars "dbname=sd4_itsmcorp_devel store=7 arg=--format=custom" ``` ``` Avalable env: store: default('1') - how long do you need to store current backup target: default('/opt/back/internal/postgres/') - where place put the archive arg: default('--exclude-table=tbl_event --format=custom') - pg_dump argument ``` #### PostgreSQL [Official documentaiton.](https://www.postgresql.org/docs/current/static/app-pgdump.html) Example: ``` pg_dump --format "custom" --file "/opt/back/internal/postgres/{{ dbname }}.bak" {{ dbname }} ``` ## Supported Databases For now supports: * PostgreSQL ## Supported OS Linux