mirror of
https://github.com/krislamo/puppet-rsnapshot
synced 2024-11-10 00:00:35 +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
|
||||
#
|
||||
<%@commands.each do |command| -%>
|
||||
ssh <%=@host-%> '<%=command-%>'
|
||||
ssh -l <%=@backup_user-%> <%=@host-%> '<%=command-%>'
|
||||
|
||||
<%end-%>
|
||||
|
@ -9,18 +9,18 @@ pass=<%=@dbbackup_password%>
|
||||
|
||||
<% if (@dbbackup_user == 'root' && @dbbackup_password == '') -%>
|
||||
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-%>
|
||||
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-%>
|
||||
for db in "${dbs[@]}"; do
|
||||
<% if @dbbackup_user == 'root' -%>
|
||||
ssh -l root "$host" "<%=@dumper-%> <%=@dump_flags-%> ${db}" > "$db".sql
|
||||
<% if (@dbbackup_user == 'root' && @dbbackup_password = '' )-%>
|
||||
ssh -l <%=@backup_user-%> "$host" "<%=@dumper-%> <%=@dump_flags-%> ${db}" > "$db".sql
|
||||
<%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-%>
|
||||
wait
|
||||
<% if @compress != '' -%>
|
||||
|
@ -9,10 +9,10 @@ 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-%>'\"")
|
||||
$(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
|
||||
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
|
||||
<% if @compress != '' -%>
|
||||
<%=@compress-%> "$db".sql
|
||||
|
Loading…
Reference in New Issue
Block a user