mirror of
https://github.com/krislamo/puppet-rsnapshot
synced 2024-11-10 08:10:34 +00:00
add backup script templates
This commit is contained in:
parent
d6ea0821c0
commit
d5e4ebbb9c
10
templates/misc.sh.erb
Normal file
10
templates/misc.sh.erb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# add custom stuff here
|
||||||
|
# FIXME: remember to concat for custom stuff after the last line of the puppet generated script
|
||||||
|
<% if @osfamily == 'RedHat' -%>
|
||||||
|
ssh <%=@host-%> rpm -qa --qf='%{name},' > packages.txt
|
||||||
|
<%end-%>
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++
|
16
templates/mysql.sh.erb
Normal file
16
templates/mysql.sh.erb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/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%>
|
||||||
|
|
||||||
|
dbs=( $(mysql -h "$host" -u "$user" -p"$pass" -e 'show databases' | sed '1d;/information_schema/d;/performance_schema/d') )
|
||||||
|
|
||||||
|
for db in "${dbs[@]}"; do
|
||||||
|
mysqldump --host="$host" --user="$user" --password="$pass" --single-transaction --quick --routines --ignore-table=mysql.event "$db" > "$db".sql
|
||||||
|
wait
|
||||||
|
pbzip2 -p3 "$db".sql
|
||||||
|
done
|
||||||
|
|
17
templates/psql.sh.erb
Normal file
17
templates/psql.sh.erb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/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=( $(psql -h "$host" -U "$user" -Atc "SELECT datname FROM pg_database WHERE NOT datistemplate AND datname <> 'postgres'") )
|
||||||
|
|
||||||
|
for db in "${dbs[@]}"; do
|
||||||
|
ssh -l root "$host" "pg_dump -U ${user} -Fc ${db}" > "$db".sql
|
||||||
|
wait
|
||||||
|
pbzip2 -p3 "$db".sql
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in New Issue
Block a user