mirror of
https://github.com/krislamo/puppet-rsnapshot
synced 2024-12-16 17:50:34 +00:00
parameterize backup_user in scripts templates
This commit is contained in:
parent
03e385b2aa
commit
33e3fa685a
@ -2,6 +2,6 @@
|
|||||||
#This file is managed by puppet
|
#This file is managed by puppet
|
||||||
#
|
#
|
||||||
<%@commands.each do |command| -%>
|
<%@commands.each do |command| -%>
|
||||||
ssh <%=@host-%> '<%=command-%>'
|
ssh -l <%=@backup_user-%> <%=@host-%> '<%=command-%>'
|
||||||
|
|
||||||
<%end-%>
|
<%end-%>
|
||||||
|
@ -9,18 +9,18 @@ pass=<%=@dbbackup_password%>
|
|||||||
|
|
||||||
<% if (@dbbackup_user == 'root' && @dbbackup_password == '') -%>
|
<% if (@dbbackup_user == 'root' && @dbbackup_password == '') -%>
|
||||||
dbs=(
|
dbs=(
|
||||||
$(ssh -l root "$host" "mysql -e 'show databases' | sed '1d;<%@ignore_dbs.to_a.each do |db|-%>/<%=db-%>/d;<%end-%>'" )
|
$(ssh -l <%=@backup_user-%> "$host" "mysql -e 'show databases' | sed '1d;<%@ignore_dbs.to_a.each do |db|-%>/<%=db-%>/d;<%end-%>'" )
|
||||||
)
|
)
|
||||||
<%else-%>
|
<%else-%>
|
||||||
dbs=(
|
dbs=(
|
||||||
$(ssh -l root "$host" "mysql -u <%=@dbbackup_user-%> -p'<%=@dbbackup_password-%>' -e 'show databases' | sed '1d;<%@ignore_dbs.each do |db|-%>/<%=db-%>/d;<%end-%>'" )
|
$(ssh -l <%=@backup_user-%> "$host" "mysql -u <%=@dbbackup_user-%> -p'<%=@dbbackup_password-%>' -e 'show databases' | sed '1d;<%@ignore_dbs.each do |db|-%>/<%=db-%>/d;<%end-%>'" )
|
||||||
)
|
)
|
||||||
<%end-%>
|
<%end-%>
|
||||||
for db in "${dbs[@]}"; do
|
for db in "${dbs[@]}"; do
|
||||||
<% if @dbbackup_user == 'root' -%>
|
<% if (@dbbackup_user == 'root' && @dbbackup_password = '' )-%>
|
||||||
ssh -l root "$host" "<%=@dumper-%> <%=@dump_flags-%> ${db}" > "$db".sql
|
ssh -l <%=@backup_user-%> "$host" "<%=@dumper-%> <%=@dump_flags-%> ${db}" > "$db".sql
|
||||||
<%else-%>
|
<%else-%>
|
||||||
ssh -l root "$host" "<%=@dumper-%> --user=<%=@dbbackup_user-%> --password='<%=@dbbackup_password-%>' <%=@dump_flags-%> ${db}" > "$db".sql
|
ssh -l <%=@backup_user-%> "$host" "<%=@dumper-%> --user=<%=@dbbackup_user-%> --password='<%=@dbbackup_password-%>' <%=@dump_flags-%> ${db}" > "$db".sql
|
||||||
<%end-%>
|
<%end-%>
|
||||||
wait
|
wait
|
||||||
<% if @compress != '' -%>
|
<% if @compress != '' -%>
|
||||||
|
@ -9,10 +9,10 @@ pass=<%=@dbbackup_password%>
|
|||||||
|
|
||||||
PGPASSWORD="$pass"
|
PGPASSWORD="$pass"
|
||||||
dbs=(
|
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-%>'\"")
|
$(ssh -l <%=@backup_user-%> "$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
|
for db in "${dbs[@]}"; do
|
||||||
ssh -l root "$host" "<%=@dumper-%> -U ${user} <%=@dump_flags-%> ${db}" > "$db".sql
|
ssh -l <%=@backup_user-%> "$host" "<%=@dumper-%> -U ${user} <%=@dump_flags-%> ${db}" > "$db".sql
|
||||||
wait
|
wait
|
||||||
<% if @compress != '' -%>
|
<% if @compress != '' -%>
|
||||||
<%=@compress-%> "$db".sql
|
<%=@compress-%> "$db".sql
|
||||||
|
Loading…
Reference in New Issue
Block a user