tests: make filename optional in set/delconfig

This commit is contained in:
Jerome Charaoui 2021-01-06 00:26:09 -05:00
parent bf612c9390
commit 3733864bfb
6 changed files with 240 additions and 234 deletions

View File

@ -46,50 +46,50 @@ finish_borg() {
} }
@test "check ssh connection test" { @test "check ssh connection test" {
setconfig backup.d/test.borg testconnect yes setconfig testconnect yes
setconfig backup.d/test.borg dest user $BN_REMOTEUSER setconfig dest user $BN_REMOTEUSER
setconfig backup.d/test.borg dest host $BN_REMOTEHOST setconfig dest host $BN_REMOTEHOST
testaction testaction
greplog "Debug: Connected to ${BN_REMOTEHOST} as ${BN_REMOTEUSER} successfully$" greplog "Debug: Connected to ${BN_REMOTEHOST} as ${BN_REMOTEUSER} successfully$"
} }
@test "check config parameter nicelevel" { @test "check config parameter nicelevel" {
# nicelevel is 0 by default # nicelevel is 0 by default
delconfig backup.d/test.borg nicelevel delconfig nicelevel
testaction testaction
greplog 'Debug: executing borg create$' '\bnice -n 0\b' greplog 'Debug: executing borg create$' '\bnice -n 0\b'
# nicelevel is defined # nicelevel is defined
setconfig backup.d/test.borg nicelevel -19 setconfig nicelevel -19
testaction testaction
greplog 'Debug: executing borg create$' '\bnice -n -19\b' greplog 'Debug: executing borg create$' '\bnice -n -19\b'
} }
@test "check config parameter ionicelevel" { @test "check config parameter ionicelevel" {
# no ionice by default # no ionice by default
delconfig backup.d/test.borg ionicelevel delconfig ionicelevel
testaction testaction
not_greplog 'Debug: executing borg create$' '\bionice -c2\b' not_greplog 'Debug: executing borg create$' '\bionice -c2\b'
# acceptable value # acceptable value
setconfig backup.d/test.borg ionicelevel 7 setconfig ionicelevel 7
testaction testaction
greplog 'Debug: executing borg create$' '\bionice -c2 -n 7\b' greplog 'Debug: executing borg create$' '\bionice -c2 -n 7\b'
# unacceptable value # unacceptable value
setconfig backup.d/test.borg ionicelevel 10 setconfig ionicelevel 10
testaction testaction
greplog 'Fatal: The value of ionicelevel is expected to be either empty or an integer from 0 to 7. Got: 10$' greplog 'Fatal: The value of ionicelevel is expected to be either empty or an integer from 0 to 7. Got: 10$'
} }
@test "check config parameter bwlimit" { @test "check config parameter bwlimit" {
# no limit by default # no limit by default
delconfig backup.d/test.borg bwlimit delconfig bwlimit
testaction testaction
not_greplog 'Debug: executing borg create$' '\s--remote-ratelimit=' not_greplog 'Debug: executing borg create$' '\s--remote-ratelimit='
# limit is defined # limit is defined
setconfig backup.d/test.borg bwlimit 1024 setconfig bwlimit 1024
testaction testaction
greplog 'Debug: executing borg create$' '\s--remote-ratelimit=1024\b' greplog 'Debug: executing borg create$' '\s--remote-ratelimit=1024\b'
@ -97,140 +97,138 @@ finish_borg() {
@test "check config parameter source/init" { @test "check config parameter source/init" {
# do repository init by default # do repository init by default
delconfig backup.d/test.borg source init delconfig source init
testaction testaction
greplog 'Debug: executing borg init$' greplog 'Debug: executing borg init$'
# do repository init # do repository init
setconfig backup.d/test.borg source init yes setconfig source init yes
testaction testaction
greplog 'Debug: executing borg init$' greplog 'Debug: executing borg init$'
# don't do repository init # don't do repository init
setconfig backup.d/test.borg source init no setconfig source init no
testaction testaction
not_greplog 'Debug: executing borg init$' not_greplog 'Debug: executing borg init$'
} }
@test "check config parameter source/include" { @test "check config parameter source/include" {
# missing path # missing path
delconfig backup.d/test.borg source include delconfig source include
testaction testaction
greplog 'Fatal: No source includes specified$' greplog 'Fatal: No source includes specified$'
# single path # single path
setconfig backup.d/test.borg source include "$BN_SRCDIR" setconfig source include "$BN_SRCDIR"
testaction testaction
greplog 'Debug: executing borg create$' "'${BN_SRCDIR}'$" greplog 'Debug: executing borg create$' "'${BN_SRCDIR}'$"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.borg source include "$BN_SRCDIR" /foo /bar setconfig_repeat source include "$BN_SRCDIR" /foo /bar
testaction testaction
greplog 'Debug: executing borg create$' "'${BN_SRCDIR}' '/foo' '/bar'$" greplog 'Debug: executing borg create$' "'${BN_SRCDIR}' '/foo' '/bar'$"
} }
@test "check config parameter source/exclude" { @test "check config parameter source/exclude" {
# absent path # absent path
delconfig backup.d/test.borg source exclude delconfig source exclude
testaction testaction
not_greplog 'Debug: executing borg create$' "\s--exclude\s" not_greplog 'Debug: executing borg create$' "\s--exclude\s"
# single path # single path
setconfig backup.d/test.borg source exclude "${BN_SRCDIR}/var" setconfig source exclude "${BN_SRCDIR}/var"
testaction testaction
greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var'\s" greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var'\s"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.borg source exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar" setconfig_repeat source exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar"
testaction testaction
greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s" greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s"
} }
@test "check config parameter source/create_options" { @test "check config parameter source/create_options" {
# absent parameter # absent parameter
delconfig backup.d/test.borg source create_options delconfig source create_options
testaction testaction
not_greplog 'Debug: executing borg create$' "\s--create-options\s" not_greplog 'Debug: executing borg create$' "\s--create-options\s"
# defined parameter # defined parameter
setconfig backup.d/test.borg source create_options "--exclude-caches" setconfig source create_options "--exclude-caches"
testaction testaction
greplog 'Debug: executing borg create$' "\s--exclude-caches\b" greplog 'Debug: executing borg create$' "\s--exclude-caches\b"
} }
@test "check config parameter source/prune" { @test "check config parameter source/prune" {
# absent parameter, defaults enabled # absent parameter, defaults enabled
delconfig backup.d/test.borg source prune delconfig source prune
testaction testaction
greplog 'Debug: executing borg prune$' greplog 'Debug: executing borg prune$'
# defined parameter, enabled # defined parameter, enabled
setconfig backup.d/test.borg source prune yes setconfig source prune yes
testaction testaction
greplog 'Debug: executing borg prune$' greplog 'Debug: executing borg prune$'
# defined parameter, disabled # defined parameter, disabled
setconfig backup.d/test.borg source prune no setconfig source prune no
cat "${BATS_TMPDIR}/backup.d/test.borg"
testaction testaction
not_greplog 'Debug: executing borg prune$' not_greplog 'Debug: executing borg prune$'
} }
@test "check config parameter source/keep" { @test "check config parameter source/keep" {
# absent parameter, defaults to '30d' # absent parameter, defaults to '30d'
setconfig backup.d/test.borg source prune yes setconfig source prune yes
delconfig backup.d/test.borg source keep delconfig source keep
testaction testaction
greplog 'Debug: executing borg prune$' '\s--keep-within=30d\b' greplog 'Debug: executing borg prune$' '\s--keep-within=30d\b'
# defined parameter, set to 60d # defined parameter, set to 60d
setconfig backup.d/test.borg source prune yes setconfig source prune yes
setconfig backup.d/test.borg source keep 60d setconfig source keep 60d
testaction testaction
greplog 'Debug: executing borg prune$' '\s--keep-within=60d\b' greplog 'Debug: executing borg prune$' '\s--keep-within=60d\b'
# defined parameter, disabled, set to 0 # defined parameter, disabled, set to 0
setconfig backup.d/test.borg source prune yes setconfig source prune yes
setconfig backup.d/test.borg source keep 0 setconfig source keep 0
cat "${BATS_TMPDIR}/backup.d/test.borg"
testaction testaction
not_greplog 'Debug: executing borg prune$' '\s--keep-within=' not_greplog 'Debug: executing borg prune$' '\s--keep-within='
} }
@test "check config parameter source/prune_options" { @test "check config parameter source/prune_options" {
# absent parameter # absent parameter
delconfig backup.d/test.borg source prune_options delconfig source prune_options
testaction testaction
greplog 'Debug: executing borg prune$' "Debug: borg prune --keep-within=30d ${BN_BACKUPDIR}/testborg$" greplog 'Debug: executing borg prune$' "Debug: borg prune --keep-within=30d ${BN_BACKUPDIR}/testborg$"
# defined parameter # defined parameter
setconfig backup.d/test.borg source prune_options "--save-space" setconfig source prune_options "--save-space"
testaction testaction
greplog 'Debug: executing borg prune$' '\s--save-space\b' greplog 'Debug: executing borg prune$' '\s--save-space\b'
} }
@test "check config parameter source/cache_directory" { @test "check config parameter source/cache_directory" {
# absent parameter # absent parameter
delconfig backup.d/test.borg source cache_directory delconfig source cache_directory
testaction testaction
not_greplog 'Debug: export BORG_CACHE_DIR=' not_greplog 'Debug: export BORG_CACHE_DIR='
# defined parameter # defined parameter
setconfig backup.d/test.borg source cache_directory "/var/cache/borg" setconfig source cache_directory "/var/cache/borg"
testaction testaction
greplog 'Debug: export BORG_CACHE_DIR="/var/cache/borg"$' greplog 'Debug: export BORG_CACHE_DIR="/var/cache/borg"$'
} }
@test "check config parameter dest/user" { @test "check config parameter dest/user" {
# absent parameter # absent parameter
delconfig backup.d/test.borg dest user delconfig dest user
setconfig backup.d/test.borg dest host "$BN_REMOTEHOST" setconfig dest host "$BN_REMOTEHOST"
testaction testaction
greplog 'Fatal: Destination user not set$' greplog 'Fatal: Destination user not set$'
# defined parameter # defined parameter
setconfig backup.d/test.borg dest user "$BN_REMOTEUSER" setconfig dest user "$BN_REMOTEUSER"
setconfig backup.d/test.borg dest host "$BN_REMOTEHOST" setconfig dest host "$BN_REMOTEHOST"
testaction testaction
greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 22 -l ${BN_REMOTEUSER} 'echo -n 1'" greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 22 -l ${BN_REMOTEUSER} 'echo -n 1'"
greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testborg::" greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testborg::"
@ -238,14 +236,14 @@ finish_borg() {
@test "check config parameter dest/host" { @test "check config parameter dest/host" {
# absent parameter # absent parameter
delconfig backup.d/test.borg dest host delconfig dest host
setconfig backup.d/test.borg dest user "$BN_REMOTEUSER" setconfig dest user "$BN_REMOTEUSER"
testaction testaction
greplog 'Fatal: Destination host not set$' greplog 'Fatal: Destination host not set$'
# defined parameter # defined parameter
setconfig backup.d/test.borg dest user "$BN_REMOTEUSER" setconfig dest user "$BN_REMOTEUSER"
setconfig backup.d/test.borg dest host "$BN_REMOTEHOST" setconfig dest host "$BN_REMOTEHOST"
testaction testaction
greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 22 -l ${BN_REMOTEUSER} 'echo -n 1'" greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 22 -l ${BN_REMOTEUSER} 'echo -n 1'"
greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testborg::" greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testborg::"
@ -253,17 +251,17 @@ finish_borg() {
@test "check config parameter dest/port" { @test "check config parameter dest/port" {
# absent parameter, defaults to 22 # absent parameter, defaults to 22
setconfig backup.d/test.borg dest user "$BN_REMOTEUSER" setconfig dest user "$BN_REMOTEUSER"
setconfig backup.d/test.borg dest host "$BN_REMOTEHOST" setconfig dest host "$BN_REMOTEHOST"
delconfig backup.d/test.borg dest port delconfig dest port
testaction testaction
greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 22 -l ${BN_REMOTEUSER} 'echo -n 1'" greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 22 -l ${BN_REMOTEUSER} 'echo -n 1'"
greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testborg::" greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testborg::"
# defined parameter # defined parameter
setconfig backup.d/test.borg dest port 7722 setconfig dest port 7722
setconfig backup.d/test.borg dest user "$BN_REMOTEUSER" setconfig dest user "$BN_REMOTEUSER"
setconfig backup.d/test.borg dest host "$BN_REMOTEHOST" setconfig dest host "$BN_REMOTEHOST"
testaction testaction
greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 7722 -l ${BN_REMOTEUSER} 'echo -n 1'" greplog "Debug: ssh -o PasswordAuthentication=no ${BN_REMOTEHOST} -p 7722 -l ${BN_REMOTEUSER} 'echo -n 1'"
greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:7722${BN_BACKUPDIR}/testborg::" greplog 'Debug: executing borg create$' "\bssh://${BN_REMOTEUSER}@${BN_REMOTEHOST}:7722${BN_BACKUPDIR}/testborg::"
@ -271,45 +269,45 @@ finish_borg() {
@test "check config parameter dest/directory" { @test "check config parameter dest/directory" {
# absent parameter # absent parameter
delconfig backup.d/test.borg dest directory delconfig dest directory
testaction testaction
greplog 'Fatal: Destination directory not set$' greplog 'Fatal: Destination directory not set$'
# defined parameter # defined parameter
setconfig backup.d/test.borg dest directory "${BN_BACKUPDIR}/testborg" setconfig dest directory "${BN_BACKUPDIR}/testborg"
testaction testaction
greplog 'Debug: executing borg create$' "\s${BN_BACKUPDIR}/testborg::" greplog 'Debug: executing borg create$' "\s${BN_BACKUPDIR}/testborg::"
} }
@test "check config parameter dest/archive" { @test "check config parameter dest/archive" {
# absent parameter, defaults to {now:%Y-%m-%dT%H:%M:%S} # absent parameter, defaults to {now:%Y-%m-%dT%H:%M:%S}
delconfig backup.d/test.borg dest archive delconfig dest archive
testaction testaction
greplog 'Debug: executing borg create$' "\s${BN_BACKUPDIR}/testborg::{now:%Y-%m-%dT%H:%M:%S}" greplog 'Debug: executing borg create$' "\s${BN_BACKUPDIR}/testborg::{now:%Y-%m-%dT%H:%M:%S}"
# defined parameter # defined parameter
setconfig backup.d/test.borg dest archive foo setconfig dest archive foo
testaction testaction
greplog 'Debug: executing borg create$' "\s${BN_BACKUPDIR}/testborg::foo" greplog 'Debug: executing borg create$' "\s${BN_BACKUPDIR}/testborg::foo"
} }
@test "check config parameter dest/compression" { @test "check config parameter dest/compression" {
# absent parameter, defaults to lz4 # absent parameter, defaults to lz4
delconfig backup.d/test.borg dest compression delconfig dest compression
testaction testaction
greplog 'Debug: executing borg create$' "\s--compression lz4\b" greplog 'Debug: executing borg create$' "\s--compression lz4\b"
# defined parameter # defined parameter
setconfig backup.d/test.borg dest compression auto,zstd,13 setconfig dest compression auto,zstd,13
testaction testaction
greplog 'Debug: executing borg create$' "\s--compression auto,zstd,13\b" greplog 'Debug: executing borg create$' "\s--compression auto,zstd,13\b"
} }
@test "create local backup without encryption" { @test "create local backup without encryption" {
# no encryption, no passphrase # no encryption, no passphrase
setconfig backup.d/test.borg dest archive testarchive setconfig dest archive testarchive
setconfig backup.d/test.borg dest encryption none setconfig dest encryption none
delconfig backup.d/test.borg dest passphrase delconfig dest passphrase
cleanup_backups local cleanup_backups local
runaction runaction
greplog 'Debug: executing borg init$' 'Debug: borg init --encryption=none' greplog 'Debug: executing borg init$' 'Debug: borg init --encryption=none'
@ -323,9 +321,9 @@ finish_borg() {
@test "create local backup with encryption" { @test "create local backup with encryption" {
# encryption enabled, wrong passphrase # encryption enabled, wrong passphrase
setconfig backup.d/test.borg dest archive testarchive setconfig dest archive testarchive
setconfig backup.d/test.borg dest encryption repokey setconfig dest encryption repokey
setconfig backup.d/test.borg dest passphrase 123test setconfig dest passphrase 123test
cleanup_backups local cleanup_backups local
runaction runaction
greplog 'Debug: executing borg init$' 'Debug: borg init --encryption=repokey' greplog 'Debug: executing borg init$' 'Debug: borg init --encryption=repokey'
@ -341,11 +339,11 @@ finish_borg() {
} }
@test "create remote backup with encryption" { @test "create remote backup with encryption" {
setconfig backup.d/test.borg dest archive testarchive setconfig dest archive testarchive
setconfig backup.d/test.borg dest encryption repokey setconfig dest encryption repokey
setconfig backup.d/test.borg dest passphrase 123test setconfig dest passphrase 123test
setconfig backup.d/test.borg dest host "${BN_REMOTEHOST}" setconfig dest host "${BN_REMOTEHOST}"
setconfig backup.d/test.borg dest user "${BN_REMOTEUSER}" setconfig dest user "${BN_REMOTEUSER}"
cleanup_backups remote cleanup_backups remote
runaction runaction
greplog 'Debug: executing borg init$' 'Debug: borg init --encryption=repokey' greplog 'Debug: executing borg init$' 'Debug: borg init --encryption=repokey'

View File

@ -81,12 +81,19 @@ teardown() {
# set parameter/value in action config file # set parameter/value in action config file
setconfig() { setconfig() {
if [ -z $4 ]; then if [ -f "${BATS_TMPDIR}/$1" ]; then
# default section local CONFIGFILE="${BATS_TMPDIR}/$1"
crudini --set "${BATS_TMPDIR}/$1" '' $2 "$3" shift
else else
local COMP=$(basename -s .bats "${BATS_TEST_FILENAME}")
local CONFIGFILE="${BATS_TMPDIR}/backup.d/test.${COMP}"
fi
if [ -n "$3" ]; then
# named section # named section
crudini --set "${BATS_TMPDIR}/$1" $2 $3 "$4" crudini --set "$CONFIGFILE" "$1" "$2" "$3"
else
# default section
crudini --set "$CONFIGFILE" '' "$1" "$2"
fi fi
} }
@ -94,25 +101,38 @@ setconfig() {
# crudini doesn't support those # crudini doesn't support those
# (used for include and exclude parameters) # (used for include and exclude parameters)
setconfig_repeat() { setconfig_repeat() {
conffile="${BATS_TMPDIR}/$1" if [ -f "${BATS_TMPDIR}/$1" ]; then
section="$2" local CONFIGFILE="${BATS_TMPDIR}/$1"
param="$3" shift
shift 3 else
crudini --del "$conffile" "$section" "$param" local COMP=$(basename -s .bats "${BATS_TEST_FILENAME}")
local CONFIGFILE="${BATS_TMPDIR}/backup.d/test.${COMP}"
fi
local SECTION="$1"
local PARAM="$2"
shift 2
crudini --del "$CONFIGFILE" "$SECTION" "$PARAM"
for v; do for v; do
crudini --set --list --list-sep=$'\nREPEAT = ' "$conffile" "$section" "$param" "$v" crudini --set --list --list-sep=$'\nREPEAT = ' "$CONFIGFILE" "$SECTION" "$PARAM" "$v"
done done
sed -i "s#^\s\+REPEAT =#${param} =#" "${conffile}" sed -i "s#^\s\+REPEAT =#${PARAM} =#" "$CONFIGFILE"
} }
# delete config parameter # delete config parameter
delconfig() { delconfig() {
if [ -z $3 ]; then if [ -f "${BATS_TMPDIR}/$1" ]; then
# default section local CONFIGFILE="${BATS_TMPDIR}/$1"
crudini --del "${BATS_TMPDIR}/$1" '' $2 shift
else else
local COMP=$(basename -s .bats "${BATS_TEST_FILENAME}")
local CONFIGFILE="${BATS_TMPDIR}/backup.d/test.${COMP}"
fi
if [ -n "$2" ]; then
# named section # named section
crudini --del "${BATS_TMPDIR}/$1" $2 $3 crudini --del "$CONFIGFILE" "$1" "$2"
else
# default section
crudini --del "$CONFIGFILE" '' "$1"
fi fi
} }

View File

@ -63,162 +63,162 @@ finish_dup() {
} }
@test "check ssh connection test" { @test "check ssh connection test" {
setconfig backup.d/test.dup testconnect yes setconfig testconnect yes
setconfig backup.d/test.dup dest destuser $BN_REMOTEUSER setconfig dest destuser $BN_REMOTEUSER
setconfig backup.d/test.dup dest desthost $BN_REMOTEHOST setconfig dest desthost $BN_REMOTEHOST
delconfig backup.d/test.dup dest desturl delconfig dest desturl
testaction testaction
greplog "Debug: Connected to ${BN_REMOTEHOST} as ${BN_REMOTEUSER} successfully$" greplog "Debug: Connected to ${BN_REMOTEHOST} as ${BN_REMOTEUSER} successfully$"
} }
@test "check config parameter nicelevel" { @test "check config parameter nicelevel" {
# nicelevel is 0 by default # nicelevel is 0 by default
delconfig backup.d/test.dup nicelevel delconfig nicelevel
testaction testaction
greplog 'Debug: executing duplicity$' '\bnice -n 0\b' greplog 'Debug: executing duplicity$' '\bnice -n 0\b'
# nicelevel is defined # nicelevel is defined
setconfig backup.d/test.dup nicelevel -19 setconfig nicelevel -19
testaction testaction
greplog 'Debug: executing duplicity$' '\bnice -n -19\b' greplog 'Debug: executing duplicity$' '\bnice -n -19\b'
} }
@test "check config parameter ionicelevel" { @test "check config parameter ionicelevel" {
# no ionice by default # no ionice by default
delconfig backup.d/test.dup ionicelevel delconfig ionicelevel
testaction testaction
not_greplog 'Debug: executing duplicity$' '\bionice -c2\b' not_greplog 'Debug: executing duplicity$' '\bionice -c2\b'
# acceptable value # acceptable value
setconfig backup.d/test.dup ionicelevel 7 setconfig ionicelevel 7
testaction testaction
greplog 'Debug: executing duplicity$' '\bionice -c2 -n 7\b' greplog 'Debug: executing duplicity$' '\bionice -c2 -n 7\b'
# unacceptable value # unacceptable value
setconfig backup.d/test.dup ionicelevel 10 setconfig ionicelevel 10
testaction testaction
greplog 'Fatal: The value of ionicelevel is expected to be either empty or an integer from 0 to 7. Got: 10$' greplog 'Fatal: The value of ionicelevel is expected to be either empty or an integer from 0 to 7. Got: 10$'
} }
@test "check config parameter options" { @test "check config parameter options" {
setconfig backup.d/test.dup options "--verbosity 8" setconfig options "--verbosity 8"
testaction testaction
greplog 'Debug: executing duplicity$' '\s--verbosity 8\b' greplog 'Debug: executing duplicity$' '\s--verbosity 8\b'
} }
@test "check config parameter tmpdir" { @test "check config parameter tmpdir" {
# tmpdir undefined # tmpdir undefined
delconfig backup.d/test.dup tmpdir delconfig tmpdir
testaction testaction
not_greplog 'Debug: executing duplicity$' '\s--tmpdir\b' not_greplog 'Debug: executing duplicity$' '\s--tmpdir\b'
# tmpdir defined # tmpdir defined
setconfig backup.d/test.dup tmpdir /tmp setconfig tmpdir /tmp
testaction testaction
not_greplog 'Debug: executing duplicity$' '\s--tmpdir /tmp\b' not_greplog 'Debug: executing duplicity$' '\s--tmpdir /tmp\b'
} }
@test "check config parameter source/include" { @test "check config parameter source/include" {
# missing path # missing path
delconfig backup.d/test.dup source include delconfig source include
testaction testaction
greplog 'Fatal: No source includes specified.$' greplog 'Fatal: No source includes specified.$'
# single path # single path
setconfig backup.d/test.dup source include "$BN_SRCDIR" setconfig source include "$BN_SRCDIR"
testaction testaction
greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}'" greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}'"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.dup source include "$BN_SRCDIR" /foo /bar setconfig_repeat source include "$BN_SRCDIR" /foo /bar
testaction testaction
greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}' --include '/foo' --include '/bar'\s" greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}' --include '/foo' --include '/bar'\s"
} }
@test "check config parameter source/exclude" { @test "check config parameter source/exclude" {
# absent path # absent path
delconfig backup.d/test.dup source exclude delconfig source exclude
testaction testaction
greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}' --exclude '\*\*' /\s" greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}' --exclude '\*\*' /\s"
# single path # single path
setconfig backup.d/test.dup source exclude "${BN_SRCDIR}/var" setconfig source exclude "${BN_SRCDIR}/var"
testaction testaction
greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var'\s" greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var'\s"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.dup source exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar" setconfig_repeat source exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar"
testaction testaction
greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s" greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s"
} }
@test "check config parameter dest/incremental" { @test "check config parameter dest/incremental" {
# absent parameter, defaults to yes # absent parameter, defaults to yes
delconfig backup.d/test.dup dest incremental delconfig dest incremental
testaction testaction
greplog 'Debug: executing duplicity$' 'Debug: nice -n 0 LC_ALL=C duplicity --no-print-statistics' greplog 'Debug: executing duplicity$' 'Debug: nice -n 0 LC_ALL=C duplicity --no-print-statistics'
# defined, set to yes # defined, set to yes
setconfig backup.d/test.dup dest incremental yes setconfig dest incremental yes
testaction testaction
greplog 'Debug: executing duplicity$' 'Debug: nice -n 0 LC_ALL=C duplicity --no-print-statistics' greplog 'Debug: executing duplicity$' 'Debug: nice -n 0 LC_ALL=C duplicity --no-print-statistics'
# defined, set to no # defined, set to no
setconfig backup.d/test.dup dest incremental no setconfig dest incremental no
testaction testaction
greplog 'Debug: executing duplicity$' 'Debug: nice -n 0 LC_ALL=C duplicity full --no-print-statistics' greplog 'Debug: executing duplicity$' 'Debug: nice -n 0 LC_ALL=C duplicity full --no-print-statistics'
} }
@test "check config parameter dest/increments" { @test "check config parameter dest/increments" {
# absent parameter, defaults to 30 # absent parameter, defaults to 30
delconfig backup.d/test.dup dest increments delconfig dest increments
testaction testaction
greplog 'Debug: executing duplicity$' '\s--full-if-older-than 30D\b' greplog 'Debug: executing duplicity$' '\s--full-if-older-than 30D\b'
# defined, set to 60 # defined, set to 60
setconfig backup.d/test.dup dest increments 60 setconfig dest increments 60
testaction testaction
greplog 'Debug: executing duplicity$' '\s--full-if-older-than 60D\b' greplog 'Debug: executing duplicity$' '\s--full-if-older-than 60D\b'
# defined, set to keep # defined, set to keep
setconfig backup.d/test.dup dest increments keep setconfig dest increments keep
testaction testaction
not_greplog 'Debug: executing duplicity$' '\s--full-if-older-than\s' not_greplog 'Debug: executing duplicity$' '\s--full-if-older-than\s'
} }
@test "check config parameter dest/keep" { @test "check config parameter dest/keep" {
# absent parameter, defaults to 60 # absent parameter, defaults to 60
delconfig backup.d/test.dup dest keep delconfig dest keep
testaction testaction
greplog 'Debug: executing duplicity remove-older-than$' '\sduplicity remove-older-than 60D\b' greplog 'Debug: executing duplicity remove-older-than$' '\sduplicity remove-older-than 60D\b'
# defined, set to 180 # defined, set to 180
setconfig backup.d/test.dup dest keep 180 setconfig dest keep 180
testaction testaction
greplog 'Debug: executing duplicity remove-older-than$' '\sduplicity remove-older-than 180D\b' greplog 'Debug: executing duplicity remove-older-than$' '\sduplicity remove-older-than 180D\b'
# defined, set to yes # defined, set to yes
setconfig backup.d/test.dup dest keep yes setconfig dest keep yes
testaction testaction
not_greplog 'Debug: executing duplicity remove-older-than$' not_greplog 'Debug: executing duplicity remove-older-than$'
} }
@test "check config parameter dest/keepincroffulls" { @test "check config parameter dest/keepincroffulls" {
# absent parameter, defaults to all # absent parameter, defaults to all
setconfig backup.d/test.dup dest keep 30 setconfig dest keep 30
delconfig backup.d/test.dup dest keepincroffulls delconfig dest keepincroffulls
testaction testaction
not_greplog 'Debug: executing duplicity remove-all-inc-of-but-n-full$' not_greplog 'Debug: executing duplicity remove-all-inc-of-but-n-full$'
# defined, set to 1 # defined, set to 1
setconfig backup.d/test.dup dest keep 30 setconfig dest keep 30
setconfig backup.d/test.dup dest keepincroffulls 1 setconfig dest keepincroffulls 1
testaction testaction
greplog 'Debug: executing duplicity remove-all-inc-of-but-n-full$' '\sduplicity remove-all-inc-of-but-n-full 1\b' greplog 'Debug: executing duplicity remove-all-inc-of-but-n-full$' '\sduplicity remove-all-inc-of-but-n-full 1\b'
# defined, set to all # defined, set to all
setconfig backup.d/test.dup dest keep 30 setconfig dest keep 30
setconfig backup.d/test.dup dest keepincroffulls all setconfig dest keepincroffulls all
testaction testaction
not_greplog 'Debug: executing duplicity remove-all-inc-of-but-n-full$' not_greplog 'Debug: executing duplicity remove-all-inc-of-but-n-full$'
} }
@ -261,59 +261,59 @@ finish_dup() {
@test "check config parameter dest/sshoptions" { @test "check config parameter dest/sshoptions" {
# undefined # undefined
delconfig backup.d/test.dup dest sshoptions delconfig dest sshoptions
testaction testaction
greplog 'Debug: executing duplicity$' "\s--ssh-options ''\s" greplog 'Debug: executing duplicity$' "\s--ssh-options ''\s"
# defined # defined
setconfig backup.d/test.dup dest sshoptions "-oIdentityFile=/root/.ssh/id_rsa" setconfig dest sshoptions "-oIdentityFile=/root/.ssh/id_rsa"
testaction testaction
greplog 'Debug: executing duplicity$' "\s--ssh-options '-oIdentityFile=/root/.ssh/id_rsa'\s" greplog 'Debug: executing duplicity$' "\s--ssh-options '-oIdentityFile=/root/.ssh/id_rsa'\s"
} }
@test "check config parameter dest/bandwidthlimit" { @test "check config parameter dest/bandwidthlimit" {
# undefined, disabled by default # undefined, disabled by default
delconfig backup.d/test.dup dest bandwidthlimit delconfig dest bandwidthlimit
testaction testaction
not_greplog "\btrickle -s\b" not_greplog "\btrickle -s\b"
# defined, set to 250, local file path # defined, set to 250, local file path
setconfig backup.d/test.dup dest bandwidthlimit 250 setconfig dest bandwidthlimit 250
setconfig backup.d/test.dup dest desturl "file://${BN_BACKUPDIR}/testdup" setconfig dest desturl "file://${BN_BACKUPDIR}/testdup"
testaction testaction
greplog 'Warning: The bandwidthlimit option is not used with a local file path destination.' greplog 'Warning: The bandwidthlimit option is not used with a local file path destination.'
not_greplog 'Debug: executing duplicity$' "\strickle -s -d 250 -u 250 duplicity\s" not_greplog 'Debug: executing duplicity$' "\strickle -s -d 250 -u 250 duplicity\s"
# defined, set to 250, remote path # defined, set to 250, remote path
setconfig backup.d/test.dup dest bandwidthlimit 250 setconfig dest bandwidthlimit 250
setconfig backup.d/test.dup dest desturl "sftp://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testdup" setconfig dest desturl "sftp://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testdup"
testaction testaction
greplog 'Debug: executing duplicity$' "\strickle -s -d 250 -u 250 duplicity\s" greplog 'Debug: executing duplicity$' "\strickle -s -d 250 -u 250 duplicity\s"
} }
@test "check config parameter dest/desturl" { @test "check config parameter dest/desturl" {
# undefined desturl # undefined desturl
delconfig backup.d/test.dup dest desturl delconfig dest desturl
delconfig backup.d/test.dup dest desthost delconfig dest desthost
testaction testaction
greplog 'Fatal: The destination host (desthost) must be set when desturl is not used.$' greplog 'Fatal: The destination host (desthost) must be set when desturl is not used.$'
# desturl, file protocol # desturl, file protocol
setconfig backup.d/test.dup dest desturl "file://${BN_BACKUPDIR}/testdup" setconfig dest desturl "file://${BN_BACKUPDIR}/testdup"
testaction testaction
greplog 'Debug: executing duplicity$' "\sfile://${BN_BACKUPDIR}/testdup$" greplog 'Debug: executing duplicity$' "\sfile://${BN_BACKUPDIR}/testdup$"
# desturl, sftp protocol # desturl, sftp protocol
setconfig backup.d/test.dup dest desturl "sftp://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testdup" setconfig dest desturl "sftp://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testdup"
testaction testaction
greplog 'Debug: executing duplicity$' "\ssftp://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testdup$" greplog 'Debug: executing duplicity$' "\ssftp://${BN_REMOTEUSER}@${BN_REMOTEHOST}:22${BN_BACKUPDIR}/testdup$"
} }
@test "check config parameters dest/desthost, dest/destuser, dest/destdir" { @test "check config parameters dest/desthost, dest/destuser, dest/destdir" {
delconfig backup.d/test.dup dest desturl delconfig dest desturl
setconfig backup.d/test.dup dest desthost "$BN_REMOTEHOST" setconfig dest desthost "$BN_REMOTEHOST"
setconfig backup.d/test.dup dest destuser "$BN_REMOTEUSER" setconfig dest destuser "$BN_REMOTEUSER"
setconfig backup.d/test.dup dest destdir "$BN_BACKUPDIR/testdup" setconfig dest destdir "$BN_BACKUPDIR/testdup"
testaction testaction
greplog 'Debug: executing duplicity$' "\sscp://${BN_REMOTEUSER}@${BN_REMOTEHOST}/${BN_BACKUPDIR}/testdup$" greplog 'Debug: executing duplicity$' "\sscp://${BN_REMOTEUSER}@${BN_REMOTEHOST}/${BN_BACKUPDIR}/testdup$"
} }
@ -321,9 +321,9 @@ finish_dup() {
@test "create local backup with symmetric encryption" { @test "create local backup with symmetric encryption" {
cleanup_backups local cleanup_backups local
mkdir -p /var/backups/testdup mkdir -p /var/backups/testdup
setconfig backup.d/test.dup gpg password 123test setconfig gpg password 123test
setconfig backup.d/test.dup dest desturl "file://${BN_BACKUPDIR}/testdup" setconfig dest desturl "file://${BN_BACKUPDIR}/testdup"
delconfig backup.d/test.dup dest destdir delconfig dest destdir
runaction runaction
greplog "Debug: Data will be encrypted using symmetric encryption." greplog "Debug: Data will be encrypted using symmetric encryption."
greplog "Info: Duplicity finished successfully." greplog "Info: Duplicity finished successfully."
@ -341,10 +341,10 @@ finish_dup() {
makegpgkeys makegpgkeys
cleanup_backups local cleanup_backups local
mkdir -p /var/backups/testdup mkdir -p /var/backups/testdup
setconfig backup.d/test.dup gpg encryptkey "$BN_ENCRYPTKEY" setconfig gpg encryptkey "$BN_ENCRYPTKEY"
setconfig backup.d/test.dup gpg password 123test setconfig gpg password 123test
setconfig backup.d/test.dup dest desturl "file://${BN_BACKUPDIR}/testdup" setconfig dest desturl "file://${BN_BACKUPDIR}/testdup"
delconfig backup.d/test.dup dest destdir delconfig dest destdir
runaction runaction
greplog "Debug: Data will be encrypted with the GnuPG key $BN_ENCRYPTKEY.$" greplog "Debug: Data will be encrypted with the GnuPG key $BN_ENCRYPTKEY.$"
greplog "Debug: Data won't be signed." greplog "Debug: Data won't be signed."
@ -364,11 +364,11 @@ finish_dup() {
makegpgkeys makegpgkeys
cleanup_backups local cleanup_backups local
mkdir -p /var/backups/testdup mkdir -p /var/backups/testdup
setconfig backup.d/test.dup gpg encryptkey "$BN_ENCRYPTKEY" setconfig gpg encryptkey "$BN_ENCRYPTKEY"
setconfig backup.d/test.dup gpg password 123encrypt setconfig gpg password 123encrypt
setconfig backup.d/test.dup gpg sign yes setconfig gpg sign yes
setconfig backup.d/test.dup dest desturl "file://${BN_BACKUPDIR}/testdup" setconfig dest desturl "file://${BN_BACKUPDIR}/testdup"
delconfig backup.d/test.dup dest destdir delconfig dest destdir
runaction runaction
greplog "Debug: Data will be encrypted ang signed with the GnuPG key ${BN_ENCRYPTKEY}.$" greplog "Debug: Data will be encrypted ang signed with the GnuPG key ${BN_ENCRYPTKEY}.$"
greplog "Info: Duplicity finished successfully." greplog "Info: Duplicity finished successfully."
@ -387,13 +387,13 @@ finish_dup() {
makegpgkeys makegpgkeys
cleanup_backups local cleanup_backups local
mkdir -p /var/backups/testdup mkdir -p /var/backups/testdup
setconfig backup.d/test.dup gpg encryptkey "$BN_ENCRYPTKEY" setconfig gpg encryptkey "$BN_ENCRYPTKEY"
setconfig backup.d/test.dup gpg password 123encrypt setconfig gpg password 123encrypt
setconfig backup.d/test.dup gpg sign yes setconfig gpg sign yes
setconfig backup.d/test.dup gpg signkey "$BN_SIGNKEY" setconfig gpg signkey "$BN_SIGNKEY"
setconfig backup.d/test.dup gpg signpassword 123sign setconfig gpg signpassword 123sign
setconfig backup.d/test.dup dest desturl "file://${BN_BACKUPDIR}/testdup" setconfig dest desturl "file://${BN_BACKUPDIR}/testdup"
delconfig backup.d/test.dup dest destdir delconfig dest destdir
runaction runaction
greplog "Debug: Data will be encrypted with the GnuPG key ${BN_ENCRYPTKEY}.$" greplog "Debug: Data will be encrypted with the GnuPG key ${BN_ENCRYPTKEY}.$"
greplog "Debug: Data will be signed with the GnuPG key ${BN_SIGNKEY}.$" greplog "Debug: Data will be signed with the GnuPG key ${BN_SIGNKEY}.$"
@ -410,11 +410,11 @@ finish_dup() {
} }
@test "create remote backup with symmetric encryption" { @test "create remote backup with symmetric encryption" {
setconfig backup.d/test.dup gpg password 123test setconfig gpg password 123test
delconfig backup.d/test.dup dest desturl delconfig dest desturl
setconfig backup.d/test.dup dest destuser "$BN_REMOTEUSER" setconfig dest destuser "$BN_REMOTEUSER"
setconfig backup.d/test.dup dest desthost "$BN_REMOTEHOST" setconfig dest desthost "$BN_REMOTEHOST"
setconfig backup.d/test.dup dest destdir "${BN_BACKUPDIR}/testdup" setconfig dest destdir "${BN_BACKUPDIR}/testdup"
cleanup_backups remote cleanup_backups remote
runaction runaction
greplog "Debug: Data will be encrypted using symmetric encryption." greplog "Debug: Data will be encrypted using symmetric encryption."
@ -431,13 +431,13 @@ finish_dup() {
@test "create remote backup with public key encryption, signed with same key" { @test "create remote backup with public key encryption, signed with same key" {
makegpgkeys makegpgkeys
setconfig backup.d/test.dup gpg encryptkey "$BN_ENCRYPTKEY" setconfig gpg encryptkey "$BN_ENCRYPTKEY"
setconfig backup.d/test.dup gpg password 123encrypt setconfig gpg password 123encrypt
setconfig backup.d/test.dup gpg sign yes setconfig gpg sign yes
delconfig backup.d/test.dup dest desturl delconfig dest desturl
setconfig backup.d/test.dup dest destuser "$BN_REMOTEUSER" setconfig dest destuser "$BN_REMOTEUSER"
setconfig backup.d/test.dup dest desthost "$BN_REMOTEHOST" setconfig dest desthost "$BN_REMOTEHOST"
setconfig backup.d/test.dup dest destdir "${BN_BACKUPDIR}/testdup" setconfig dest destdir "${BN_BACKUPDIR}/testdup"
cleanup_backups remote cleanup_backups remote
runaction runaction
greplog "Debug: Data will be encrypted ang signed with the GnuPG key ${BN_ENCRYPTKEY}.$" greplog "Debug: Data will be encrypted ang signed with the GnuPG key ${BN_ENCRYPTKEY}.$"

View File

@ -30,8 +30,8 @@ teardown_mysql() {
} }
@test "sqldump: exports all databases, with compression" { @test "sqldump: exports all databases, with compression" {
setconfig backup.d/test.mysql databases all setconfig databases all
setconfig backup.d/test.mysql compress yes setconfig compress yes
runaction runaction
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ]
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_v11vJj.sql.gz" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_v11vJj.sql.gz" ]
@ -40,8 +40,8 @@ teardown_mysql() {
} }
@test "sqldump: exports all databases, without compression" { @test "sqldump: exports all databases, without compression" {
setconfig backup.d/test.mysql databases all setconfig databases all
setconfig backup.d/test.mysql compress no setconfig compress no
runaction runaction
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql" ]
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_v11vJj.sql" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_v11vJj.sql" ]
@ -50,7 +50,7 @@ teardown_mysql() {
} }
@test "sqldump: exports specific database" { @test "sqldump: exports specific database" {
setconfig backup.d/test.mysql databases bntest_v11vJj setconfig databases bntest_v11vJj
runaction runaction
[ ! -f ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz ] [ ! -f ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz ]
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_v11vJj.sql.gz" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_v11vJj.sql.gz" ]
@ -58,8 +58,8 @@ teardown_mysql() {
} }
@test "ignores: exports all databases while excluding two tables entirely" { @test "ignores: exports all databases while excluding two tables entirely" {
setconfig backup.d/test.mysql databases all setconfig databases all
setconfig backup.d/test.mysql ignores "bntest_v11vJj.cache_data bntest_v11vJj.cache_entity" setconfig ignores "bntest_v11vJj.cache_data bntest_v11vJj.cache_entity"
runaction runaction
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ]
[ "$(zgrep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz)" -eq 9 ] [ "$(zgrep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz)" -eq 9 ]
@ -70,9 +70,9 @@ teardown_mysql() {
} }
@test "nodata: exports all databases while excluding data from one table, with compression" { @test "nodata: exports all databases while excluding data from one table, with compression" {
setconfig backup.d/test.mysql databases all setconfig databases all
setconfig backup.d/test.mysql compress yes setconfig compress yes
setconfig backup.d/test.mysql nodata bntest_v11vJj.cache_data setconfig nodata bntest_v11vJj.cache_data
runaction runaction
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ]
[ "$(zgrep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz)" -eq 9 ] [ "$(zgrep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz)" -eq 9 ]
@ -82,9 +82,9 @@ teardown_mysql() {
} }
@test "nodata: exports all databases while excluding data from one table, without compression" { @test "nodata: exports all databases while excluding data from one table, without compression" {
setconfig backup.d/test.mysql databases all setconfig databases all
setconfig backup.d/test.mysql compress no setconfig compress no
setconfig backup.d/test.mysql nodata bntest_v11vJj.cache_data setconfig nodata bntest_v11vJj.cache_data
runaction runaction
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql" ]
[ "$(grep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql)" -eq 9 ] [ "$(grep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql)" -eq 9 ]
@ -94,9 +94,9 @@ teardown_mysql() {
} }
@test "nodata: exports all databases while excluding data from two tables, with compression" { @test "nodata: exports all databases while excluding data from two tables, with compression" {
setconfig backup.d/test.mysql databases all setconfig databases all
setconfig backup.d/test.mysql compress yes setconfig compress yes
setconfig backup.d/test.mysql nodata "bntest_v11vJj.cache_data bntest_v11vJj.cache_entity" setconfig nodata "bntest_v11vJj.cache_data bntest_v11vJj.cache_entity"
runaction runaction
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz" ]
[ "$(zgrep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz)" -eq 9 ] [ "$(zgrep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql.gz)" -eq 9 ]
@ -107,9 +107,9 @@ teardown_mysql() {
} }
@test "nodata: exports all databases while excluding data from two tables, without compression" { @test "nodata: exports all databases while excluding data from two tables, without compression" {
setconfig backup.d/test.mysql databases all setconfig databases all
setconfig backup.d/test.mysql compress no setconfig compress no
setconfig backup.d/test.mysql nodata "bntest_v11vJj.cache_data bntest_v11vJj.cache_entity" setconfig nodata "bntest_v11vJj.cache_data bntest_v11vJj.cache_entity"
runaction runaction
[ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql" ] [ -s "${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql" ]
[ "$(grep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql)" -eq 9 ] [ "$(grep -c 'INSERT INTO' ${BN_BACKUPDIR}/mysql/sqldump/bntest_p8Cz8k.sql)" -eq 9 ]

View File

@ -33,62 +33,56 @@ teardown_pgsql() {
} }
@test "plain: exports all databases, with compression" { @test "plain: exports all databases, with compression" {
setconfig backup.d/test.pgsql databases all setconfig databases all
setconfig backup.d/test.pgsql compress yes setconfig compress yes
setconfig backup.d/test.pgsql format plain setconfig format plain
runaction runaction
[ "$status" -eq 0 ]
gzip -tq "${BN_BACKUPDIR}/postgres/bntest0-all.sql.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest0-all.sql.gz"
} }
@test "plain: exports all databases, without compression" { @test "plain: exports all databases, without compression" {
setconfig backup.d/test.pgsql databases all setconfig databases all
setconfig backup.d/test.pgsql compress no setconfig compress no
setconfig backup.d/test.pgsql format plain setconfig format plain
runaction runaction
[ "$status" -eq 0 ]
[ -s "${BN_BACKUPDIR}/postgres/bntest0-all.sql" ] [ -s "${BN_BACKUPDIR}/postgres/bntest0-all.sql" ]
} }
@test "plain: exports specific database, with compression" { @test "plain: exports specific database, with compression" {
setconfig backup.d/test.pgsql databases bntest_v11vJj setconfig databases bntest_v11vJj
setconfig backup.d/test.pgsql compress yes setconfig compress yes
setconfig backup.d/test.pgsql format plain setconfig format plain
runaction runaction
[ "$status" -eq 0 ]
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql.gz"
[ "$(zgrep -c -e '^COPY' ${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql.gz)" -eq 68 ] [ "$(zgrep -c -e '^COPY' ${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql.gz)" -eq 68 ]
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.sql.gz" ] [ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.sql.gz" ]
} }
@test "plain: exports specific database, without compression" { @test "plain: exports specific database, without compression" {
setconfig backup.d/test.pgsql databases bntest_v11vJj setconfig databases bntest_v11vJj
setconfig backup.d/test.pgsql compress no setconfig compress no
setconfig backup.d/test.pgsql format plain setconfig format plain
runaction runaction
[ "$status" -eq 0 ]
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql" ] [ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql" ]
[ "$(grep -c -e '^COPY' ${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql)" -eq 68 ] [ "$(grep -c -e '^COPY' ${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql)" -eq 68 ]
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.sql" ] [ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.sql" ]
} }
@test "tar: exports all databases, with compression" { @test "tar: exports all databases, with compression" {
setconfig backup.d/test.pgsql databases all setconfig databases all
setconfig backup.d/test.pgsql compress yes setconfig compress yes
setconfig backup.d/test.pgsql format tar setconfig format tar
runaction runaction
[ "$status" -eq 0 ]
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz"
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
gzip -tq "${BN_BACKUPDIR}/postgres/globals.sql.gz" gzip -tq "${BN_BACKUPDIR}/postgres/globals.sql.gz"
} }
@test "tar: exports all databases, without compression" { @test "tar: exports all databases, without compression" {
setconfig backup.d/test.pgsql databases all setconfig databases all
setconfig backup.d/test.pgsql compress no setconfig compress no
setconfig backup.d/test.pgsql format tar setconfig format tar
runaction runaction
[ "$status" -eq 0 ]
[ -s "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ] [ -s "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ] [ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
file ${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump | grep "POSIX tar archive" file ${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump | grep "POSIX tar archive"
@ -97,22 +91,20 @@ teardown_pgsql() {
} }
@test "tar: exports specific database, with compression" { @test "tar: exports specific database, with compression" {
setconfig backup.d/test.pgsql databases bntest_v11vJj setconfig databases bntest_v11vJj
setconfig backup.d/test.pgsql compress yes setconfig compress yes
setconfig backup.d/test.pgsql format tar setconfig format tar
runaction runaction
[ "$status" -eq 0 ]
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" ] [ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" ]
[ ! -e "${BN_BACKUPDIR}/postgres/globals.sql.gz" ] [ ! -e "${BN_BACKUPDIR}/postgres/globals.sql.gz" ]
} }
@test "tar: exports specific database, without compression" { @test "tar: exports specific database, without compression" {
setconfig backup.d/test.pgsql databases bntest_v11vJj setconfig databases bntest_v11vJj
setconfig backup.d/test.pgsql compress no setconfig compress no
setconfig backup.d/test.pgsql format tar setconfig format tar
runaction runaction
[ "$status" -eq 0 ]
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ] [ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
file ${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump | grep -q "POSIX tar archive" file ${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump | grep -q "POSIX tar archive"
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ] [ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]
@ -120,22 +112,20 @@ teardown_pgsql() {
} }
@test "custom: exports all databases, with compression" { @test "custom: exports all databases, with compression" {
setconfig backup.d/test.pgsql databases all setconfig databases all
setconfig backup.d/test.pgsql compress yes setconfig compress yes
setconfig backup.d/test.pgsql format custom setconfig format custom
runaction runaction
[ "$status" -eq 0 ]
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz"
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
gzip -tq "${BN_BACKUPDIR}/postgres/globals.sql.gz" gzip -tq "${BN_BACKUPDIR}/postgres/globals.sql.gz"
} }
@test "custom: exports all databases, without compression" { @test "custom: exports all databases, without compression" {
setconfig backup.d/test.pgsql databases all setconfig databases all
setconfig backup.d/test.pgsql compress no setconfig compress no
setconfig backup.d/test.pgsql format custom setconfig format custom
runaction runaction
[ "$status" -eq 0 ]
[ -s "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ] [ -s "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ] [ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
file "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" | grep -q "PostgreSQL custom database dump" file "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" | grep -q "PostgreSQL custom database dump"
@ -144,22 +134,20 @@ teardown_pgsql() {
} }
@test "custom: exports specific database, with compression" { @test "custom: exports specific database, with compression" {
setconfig backup.d/test.pgsql databases bntest_v11vJj setconfig databases bntest_v11vJj
setconfig backup.d/test.pgsql compress yes setconfig compress yes
setconfig backup.d/test.pgsql format custom setconfig format custom
runaction runaction
[ "$status" -eq 0 ]
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz" gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" ] [ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" ]
[ ! -e "${BN_BACKUPDIR}/postgres/globals.sql.gz" ] [ ! -e "${BN_BACKUPDIR}/postgres/globals.sql.gz" ]
} }
@test "custom: exports specific database, without compression" { @test "custom: exports specific database, without compression" {
setconfig backup.d/test.pgsql databases bntest_v11vJj setconfig databases bntest_v11vJj
setconfig backup.d/test.pgsql compress no setconfig compress no
setconfig backup.d/test.pgsql format custom setconfig format custom
runaction runaction
[ "$status" -eq 0 ]
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ] [ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
file "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" | grep -q "PostgreSQL custom database dump" file "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" | grep -q "PostgreSQL custom database dump"
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ] [ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]

View File

@ -34,7 +34,7 @@ teardown_tar() {
} }
@test "compress compression" { @test "compress compression" {
setconfig backup.d/test.tar compress compress setconfig compress compress
runaction runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log" grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.compress) archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.compress)
@ -43,7 +43,7 @@ teardown_tar() {
} }
@test "gzip compression" { @test "gzip compression" {
setconfig backup.d/test.tar compress gzip setconfig compress gzip
runaction runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log" grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tgz) archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tgz)
@ -52,7 +52,7 @@ teardown_tar() {
} }
@test "bzip2 compression" { @test "bzip2 compression" {
setconfig backup.d/test.tar compress bzip setconfig compress bzip
runaction runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log" grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.bz2) archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.bz2)
@ -61,7 +61,7 @@ teardown_tar() {
} }
@test "xz compression" { @test "xz compression" {
setconfig backup.d/test.tar compress xz setconfig compress xz
runaction runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log" grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.xz) archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.xz)
@ -70,7 +70,7 @@ teardown_tar() {
} }
@test "zstd compression" { @test "zstd compression" {
setconfig backup.d/test.tar compress zstd setconfig compress zstd
runaction runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log" grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.zst) archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar.zst)
@ -79,7 +79,7 @@ teardown_tar() {
} }
@test "unknown compression, defaults to gzip" { @test "unknown compression, defaults to gzip" {
setconfig backup.d/test.tar compress foo setconfig compress foo
runaction runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 1 warning." "${BATS_TMPDIR}/log/backupninja.log" grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 1 warning." "${BATS_TMPDIR}/log/backupninja.log"
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tgz) archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tgz)