1
0
mirror of https://github.com/krislamo/puppet-rsnapshot synced 2024-11-14 09:00:35 +00:00
puppet-rsnapshot/templates/psql.sh.erb

21 lines
674 B
Plaintext
Raw Normal View History

2016-01-21 14:11:10 +00:00
#!/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"
2016-01-22 12:17:03 +00:00
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-%>'\"")
)
2016-01-21 14:11:10 +00:00
for db in "${dbs[@]}"; do
2016-01-22 12:17:03 +00:00
ssh -l root "$host" "<%=@dumper-%> -U ${user} <%=@dump_flags-%> ${db}" > "$db".sql
2016-01-21 14:11:10 +00:00
wait
2016-01-22 14:01:32 +00:00
<% if @compress != '' -%>
<%=@compress-%> "$db".sql
<%end-%>
2016-01-21 14:11:10 +00:00
done