1
0
mirror of https://github.com/krislamo/puppet-rsnapshot synced 2024-11-10 00:00:35 +00:00
puppet-rsnapshot/templates/psql.sh.erb
2016-01-22 13:17:03 +01:00

19 lines
630 B
Plaintext

#!/bin/bash
# written by Norbert Varzariu <loomsen@gmail.com>
# This Script is triggered by rsnapshot and dumps the specified dbs on the configured host.
#
host=<%=@host%>
user=<%=@dbbackup_user%>
pass=<%=@dbbackup_password%>
PGPASSWORD="$pass"
dbs=(
$(ssh "$host" "psql -U ${user} -Atc \"SELECT datname FROM pg_database WHERE NOT datistemplate AND NOT datname ~ '<%@ignore_dbs.each do |db|-%><%if db == @ignore_dbs.last-%><%=db-%><%else-%><%=db-%>|<%end-%><%end-%>'\"")
)
for db in "${dbs[@]}"; do
ssh -l root "$host" "<%=@dumper-%> -U ${user} <%=@dump_flags-%> ${db}" > "$db".sql
wait
pbzip2 "$db".sql
done