1
0
mirror of https://github.com/krislamo/puppet-rsnapshot synced 2024-12-16 01:30:35 +00:00

quote psql password in scripts

This commit is contained in:
Norbert Varzariu 2016-01-26 08:29:42 +01:00
parent 0c5afff356
commit a386a710b7
2 changed files with 2 additions and 5 deletions

View File

@ -5,7 +5,6 @@
#
host=<%=@host%>
user=<%=@dbbackup_user%>
pass=<%=@dbbackup_password%>
<% if (@dbbackup_user == 'root' && @dbbackup_password == '') -%>
dbs=(

View File

@ -5,14 +5,12 @@
#
host=<%=@host%>
user=<%=@dbbackup_user%>
pass=<%=@dbbackup_password%>
#PGPASSWORD="$pass"
dbs=(
$(ssh -l <%=@backup_user-%> "$host" "PGPASSWORD=${pass} 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-%>'\"")
$(ssh -l <%=@backup_user-%> "$host" "PGPASSWORD='<%=@dbbackup_password%>' 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 <%=@backup_user-%> "$host" "PGPASSWORD=${pass} <%=@dumper-%> -U ${user} <%=@dump_flags-%> ${db}" > "$db".sql
ssh -l <%=@backup_user-%> "$host" "PGPASSWORD='<%=@dbbackup_password%>' <%=@dumper-%> -U ${user} <%=@dump_flags-%> ${db}" > "$db".sql
wait
<% if @compress != '' -%>
<%=@compress-%> "$db".sql