#!/bin/bash # This file was generated by Ansible for {{ ansible_fqdn }} # Do NOT modify this file by hand! WORKDIR={{backup_work}}/{{item.name}} {% if item.source.startswith('postgresql://') %} DBNAME={{item.source.split('postgresql://')[-1]}} pg_dump -U {{backup_postgres_user}} {{ '-h ' + backup_postgres_host if backup_postgres_host else ''}} {{ ('-p %s' % backup_postgres_port) if backup_postgres_port else ''}} -c $DBNAME -f ${WORKDIR}/dump {% elif item.source.startswith('mysql://') %} DBNAME={{item.source.split('mysql://')[-1]}} mysqldump -u {{backup_mysql_user}} -p{{backup_mysql_pass}} $DBNAME > ${WORKDIR}/dump {% elif item.source.startswith('mongo://') %} mongodump --out $WORKDIR/dump {% endif %} {% for action in item.pre_actions|default([]) %} {{ action }} {% endfor %}