Skip to content

Commit 8e6eef0

Browse files
committed
escape \% in cron
Percent-signs (%) in the command, unless escaped with backslash \, will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
1 parent 950cf9a commit 8e6eef0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

manifests/backup/xtrabackup.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
$daily_cron_data = ($incremental_backups) ? {
6565
true => {
66-
'directories' => "--incremental-basedir=${backupdir} --target-dir=${backupdir}/$(date +%F_%H-%M-%S)",
66+
'directories' => "--incremental-basedir=${backupdir} --target-dir=${backupdir}/$(date +\\%F_\\%H-\\%M-\\%S)",
6767
'weekday' => '1-6',
6868
},
6969
false => {

spec/classes/mysql_backup_xtrabackup_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class { 'mysql::server': }
4444
is_expected.to contain_cron('xtrabackup-daily')
4545
.with(
4646
ensure: 'present',
47-
command: '/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp --target-dir=/tmp/$(date +%F_%H-%M-%S) --backup',
47+
command: '/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup',
4848
user: 'root',
4949
hour: '23',
5050
minute: '5',
@@ -101,7 +101,7 @@ class { 'mysql::server': }
101101
is_expected.to contain_cron('xtrabackup-daily')
102102
.with(
103103
ensure: 'present',
104-
command: '/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp --target-dir=/tmp/$(date +%F_%H-%M-%S) --backup --skip-ssl',
104+
command: '/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup --skip-ssl',
105105
user: 'root',
106106
hour: '23',
107107
minute: '5',

0 commit comments

Comments
 (0)