From 16630094cbd927c7d4e901c8f9363320f82623d9 Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Fri, 22 Jan 2016 10:40:17 +0100 Subject: [PATCH] update README to reflect for v0.4.0 changes in backup_scripts --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 637b101..a1fd3f2 100644 --- a/README.md +++ b/README.md @@ -372,7 +372,7 @@ Default is: $backup_scripts = { mysql => { dbbackup_user => 'root', - dbbackup_password => 'myFancyPassWord', + dbbackup_password => 'myPassWord', }, psql => { dbbackup_user => 'postgres', @@ -398,6 +398,8 @@ rsnapshot::hosts: backup_scripts: mysql: psql: + dbbackup_user: 'backupuser' + dbbackup_password: 'password' bazqux:de: backup_scripts: mysql: @@ -409,6 +411,43 @@ This creates - a mysql and a psql backup script for `foobar.com` using the credentials `dbbackup:hunter2` for mysql and `dbbackup:yeshorsebatterystaple` for psql - a mysql backup script for `bazqux.de` using the credentials `myuser:mypassword` +The scripts look like this: +mysql: + +```bash +#!/bin/bash +host=bazqux.de +user=myuser +pass=mypassword + +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 + +``` + +psql: + +```bash +#!/bin/bash +host=foobar.com +user=backupuser +pass=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 +``` + ### rsnapshot configuration variables Please read up on the following in the [rsnapshot manpage](http://linux.die.net/man/1/rsnapshot)