Spliting backup_dir in client runner.
Required to support different backup_dir between client and server.
Change-Id: Ic268b6714361a988269c7b485abe1712043dd0ee
diff --git a/README.rst b/README.rst
index a1bec6b..82b14f6 100644
--- a/README.rst
+++ b/README.rst
@@ -46,7 +46,7 @@
.. note:: full_backups_to_keep param states how many backup will be stored locally on xtrabackup client
-Backup client with ssh/rsync remote host with compression:
+Backup client with ssh/rsync to remote host with compression and non-default backup directory on server:
.. code-block:: yaml
@@ -63,11 +63,17 @@
password: password
target:
host: cfg01
+ server:
+ enabled: false
+ backup_dir: /srv/backup
.. note:: More options to relocate local backups can be done using salt-formula-backupninja.
+ .. note:: If the ``server`` section is ommited backups will be made to
+ default location, same on both client and server side.
-Backup server rsync
+
+Backup server rsync and non-default backup directory:
.. code-block:: yaml
@@ -80,9 +86,12 @@
xtrabackup_pub_key:
enabled: true
key: key
+ backup_dir: /srv/backup
.. note:: hours_before_full param should have the same value as is stated on xtrabackup client
+ .. note:: If the ``backup_dir`` argument is ommited backups will be made to
+ default location, same on both client and server side.
Client restore from local backups:
diff --git a/xtrabackup/files/innobackupex-client-restore.sh b/xtrabackup/files/innobackupex-client-restore.sh
index 241706b..4ac3e81 100644
--- a/xtrabackup/files/innobackupex-client-restore.sh
+++ b/xtrabackup/files/innobackupex-client-restore.sh
@@ -1,4 +1,5 @@
{%- from "xtrabackup/map.jinja" import client with context %}
+{%- from "xtrabackup/map.jinja" import server with context %}
#!/bin/sh
#
# Script to prepare and restore full and incremental backups created with innobackupex-runner.
@@ -92,12 +93,12 @@
mkdir -p $INCRBACKUPDIR;
PARENT_DIR=$INCRBACKUPDIR/$FULL;
`scp -rp xtrabackup@{{ client.target.host }}:$REMOTE_PARENT_DIR/ $INCRBACKUPDIR/ >> $scpLog 2>&1`;
- `scp -rp xtrabackup@{{ client.target.host }}:{{ client.backup_dir }}/full/$FULL/ $FULLBACKUPDIR/$FULL/ >> $scpLog 2>&1`;;
+ `scp -rp xtrabackup@{{ client.target.host }}:{{ server.backup_dir }}/full/$FULL/ $FULLBACKUPDIR/$FULL/ >> $scpLog 2>&1`;;
*full*) echo "SCP getting full backup files";
FULL=`basename $1`;
mkdir -p $FULLBACKUPDIR;
PARENT_DIR=$FULLBACKUPDIR;
- `scp -rp xtrabackup@{{ client.target.host }}:{{ client.backup_dir }}/full/$FULL/ $FULLBACKUPDIR/$FULL/ >> $scpLog 2>&1`;;
+ `scp -rp xtrabackup@{{ client.target.host }}:{{ server.backup_dir }}/full/$FULL/ $FULLBACKUPDIR/$FULL/ >> $scpLog 2>&1`;;
*) echo "Unable to scp backup files from remote host"; exit 1 ;;
esac
diff --git a/xtrabackup/files/innobackupex-client-runner.sh b/xtrabackup/files/innobackupex-client-runner.sh
index d6d3287..cafa81e 100644
--- a/xtrabackup/files/innobackupex-client-runner.sh
+++ b/xtrabackup/files/innobackupex-client-runner.sh
@@ -1,4 +1,5 @@
{%- from "xtrabackup/map.jinja" import client with context %}
+{%- from "xtrabackup/map.jinja" import server with context %}
#!/bin/sh
#
# Script to create full and incremental backups (for all databases on server) using innobackupex from Percona.
@@ -14,7 +15,8 @@
MYCNF=/etc/mysql/my.cnf
MYSQL=/usr/bin/mysql
MYSQLADMIN=/usr/bin/mysqladmin
-BACKUPDIR={{ client.backup_dir }} # Backups base directory
+BACKUPDIR={{ client.backup_dir }} # Client side backups base directory
+SERVERBACKUPDIR={{ server.backup_dir }} # Server side backups base directory
FULLBACKUPDIR=$BACKUPDIR/full # Full backups directory
INCRBACKUPDIR=$BACKUPDIR/incr # Incremental backups directory
HOURSFULLBACKUPLIFE={{ client.hours_before_full }} # Lifetime of the latest full backup in hours
@@ -132,7 +134,7 @@
ssh-keygen -R {{ client.target.host }} 2>&1 | > $rsyncLog
ssh-keyscan {{ client.target.host }} >> ~/.ssh/known_hosts 2>&1 | >> $rsyncLog
echo "Rsyncing files to remote host"
-/usr/bin/rsync -rhtPv --rsync-path=rsync --progress $BACKUPDIR/* -e ssh xtrabackup@{{ client.target.host }}:$BACKUPDIR >> $rsyncLog
+/usr/bin/rsync -rhtPv --rsync-path=rsync --progress $BACKUPDIR/* -e ssh xtrabackup@{{ client.target.host }}:$SERVERBACKUPDIR >> $rsyncLog
# Check if the rsync succeeded or failed
if ! grep -q "rsync error: " $rsyncLog; then