2020-07-08 13:51:59 +02:00
|
|
|
|
# role-postgresql-backup
|
|
|
|
|
Ansible role to automaticcally backup your postgresql database you created with ansible
|
2020-07-08 15:46:00 +02:00
|
|
|
|
|
2020-07-09 17:28:35 +02:00
|
|
|
|
Configuration
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
* required packages to create postgres dump and add a cronjob
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
required_packages:
|
|
|
|
|
- postgresql-client
|
|
|
|
|
- cron
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* Where do we store our database backups:
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
backup_dir: /var/backup/postgresql
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
+ Dateformat we use to create daily backup folder
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
date_format: '%Y-%m-%d_%H-%M'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
+ Create cronjob to run backup script?
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
cron: true
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
+ User that should run the backup script as cronjob
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
user: root
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* Minute and hour to run the cronjob
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
cron_minute: '*'
|
|
|
|
|
cron_hour: '0'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
+ Which database*(s)* do we want to backup` *(example)*
|
|
|
|
|
*The values for host and port are optional!*
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
databases:
|
|
|
|
|
- name: psql_database_name
|
|
|
|
|
user: psql_database_user
|
|
|
|
|
password: Topf_Secret1
|
|
|
|
|
host: localhost
|
|
|
|
|
port: 5432
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-21 18:31:14 +02:00
|
|
|
|
+ Export Option for pg_dump.
|
2020-07-21 18:50:01 +02:00
|
|
|
|
> - ``p`` – plain-text SQL script
|
|
|
|
|
> - ``c`` – custom-format archive
|
|
|
|
|
> - ``d`` – directory-format archive
|
|
|
|
|
> - ``t`` – tar-format archive
|
2020-07-21 18:31:14 +02:00
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
export_option: "p"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
+ save backup as tar.gz
|
|
|
|
|
```yaml
|
|
|
|
|
postgresql_backup:
|
|
|
|
|
create_tar_gz: true
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-09 17:28:35 +02:00
|
|
|
|
+ Perform basic versionscheck *(true is recomended)*
|
|
|
|
|
```
|
|
|
|
|
submodules_versioncheck: false
|
|
|
|
|
```
|
2020-07-21 18:52:06 +02:00
|
|
|
|
|
|
|
|
|
Testing
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
This role is tested with different github actions. [-> Link](https://github.com/roles-ansible/role-postgresql-backup/actions)
|
|
|
|
|
|
|
|
|
|
Feel free to add some molecule if you like!
|