From afb7427e40472c50173a3951f2fe5b3136632c4d Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 6 May 2021 10:23:50 +0200 Subject: [PATCH 01/13] exclusion de 'lxc/*/rootfs/var/lib/php/sessions' --- zzz_evobackup | 1 + 1 file changed, 1 insertion(+) diff --git a/zzz_evobackup b/zzz_evobackup index c9e4957..c277a7b 100755 --- a/zzz_evobackup +++ b/zzz_evobackup @@ -416,6 +416,7 @@ if [ "${SYNC_TASKS}" = "1" ]; then --exclude "lxc/*/rootfs/var/apt" \ --exclude "lxc/*/rootfs/var/cache" \ --exclude "lxc/*/rootfs/var/lib/php5" \ + --exclude "lxc/*/rootfs/var/lib/php/sessions" \ --exclude "lxc/*/rootfs/var/lock" \ --exclude "lxc/*/rootfs/var/log" \ --exclude "lxc/*/rootfs/var/run" \ From 582e8e0c9cac76049aa3b349c19c666ff37897e5 Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Tue, 25 May 2021 20:55:00 +0200 Subject: [PATCH 02/13] Use of fstat instead of netstat on OpenBSD Allow to know which PID is listening to a port --- zzz_evobackup | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zzz_evobackup b/zzz_evobackup index c277a7b..094550b 100755 --- a/zzz_evobackup +++ b/zzz_evobackup @@ -313,8 +313,9 @@ if [ "${LOCAL_TASKS}" = "1" ]; then ${FINDMNT_BIN} > ${LOCAL_BACKUP_DIR}/findmnt.txt fi else - ## Dump network connections with netstat - netstat -finet -atn > ${LOCAL_BACKUP_DIR}/netstat.out + ## Dump network connections with fstat + fstat | head -1 > ${LOCAL_BACKUP_DIR}/netstat.out + fstat | grep internet >> ${LOCAL_BACKUP_DIR}/netstat.out ## List OpenBSD packages pkg_info -m > ${LOCAL_BACKUP_DIR}/packages From 0090595d40d1b8aa29dd6d762ae56661212ed924 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Wed, 9 Jun 2021 17:16:26 +0200 Subject: [PATCH 03/13] zzz_evobackup: commands to purge previous dumps --- zzz_evobackup | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/zzz_evobackup b/zzz_evobackup index 094550b..45c636d 100755 --- a/zzz_evobackup +++ b/zzz_evobackup @@ -152,6 +152,12 @@ if [ "${LOCAL_TASKS}" = "1" ]; then ## MySQL + ## Purge previous dumps + # rm -f ${LOCAL_BACKUP_DIR}/mysql.*.gz + # rm -rf ${LOCAL_BACKUP_DIR}/mysql + # rm -rf ${LOCAL_BACKUP_DIR}/mysqlhotcopy + # rm -rf /home/mysqldump + ## example with global and compressed mysqldump # mysqldump --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 \ # --opt --all-databases --force --events --hex-blob | gzip --best > ${LOCAL_BACKUP_DIR}/mysql.bak.gz @@ -189,7 +195,7 @@ if [ "${LOCAL_TASKS}" = "1" ]; then ## example with mysqlhotcopy # mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/mysqlhotcopy/ - # mysqlhotcopy BASE ${LOCAL_BACKUP_DIR}/mysql/mysqlhotcopy/ + # mysqlhotcopy MYBASE ${LOCAL_BACKUP_DIR}/mysqlhotcopy/ ## example for multiples MySQL instances # mysqladminpasswd=$(grep -m1 'password = .*' /root/.my.cnf|cut -d" " -f3) @@ -197,12 +203,15 @@ if [ "${LOCAL_TASKS}" = "1" ]; then # instance=$(echo "$instance"|awk '{ print $3 }') # if [ "$instance" != "3306" ] # then - # mysqldump -P $instance --opt --all-databases --hex-blob -u mysqladmin -p$mysqladminpasswd > ${LOCAL_BACKUP_DIR}/mysql.$instance.bak + # mysqldump -P $instance --opt --all-databases --hex-blob -u mysqladmin -p$mysqladminpasswd | gzip --best > ${LOCAL_BACKUP_DIR}/mysql.$instance.bak.gz # fi # done ## PostgreSQL + ## Purge previous dumps + # rm ${LOCAL_BACKUP_DIR}/pg.*.gz + # rm ${LOCAL_BACKUP_DIR}/pg-backup.tar ## example with pg_dumpall (warning: you need space in ~postgres) # su - postgres -c "pg_dumpall > ~/pg.dump.bak" # mv ~postgres/pg.dump.bak ${LOCAL_BACKUP_DIR}/ @@ -222,7 +231,8 @@ if [ "${LOCAL_TASKS}" = "1" ]; then ## don't forget to create use with read-only access ## > use admin ## > db.createUser( { user: "mongobackup", pwd: "PASS", roles: [ "backup", ] } ) - # test -d ${LOCAL_BACKUP_DIR}/mongodump/ && rm -rf ${LOCAL_BACKUP_DIR}/mongodump/ + ## Purge previous dumps + # rm -rf ${LOCAL_BACKUP_DIR}/mongodump/ # mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/mongodump/ # mongodump --quiet -u mongobackup -pPASS -o ${LOCAL_BACKUP_DIR}/mongodump/ # if [ $? -ne 0 ]; then @@ -231,9 +241,13 @@ if [ "${LOCAL_TASKS}" = "1" ]; then ## Redis + ## Purge previous dumps + # rm -rf ${LOCAL_BACKUP_DIR}/redis/ + # rm -rf ${LOCAL_BACKUP_DIR}/redis-* ## example with copy .rdb file ## for the default instance : - # cp /var/lib/redis/dump.rdb ${LOCAL_BACKUP_DIR}/ + # mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/redis/ + # cp /var/lib/redis/dump.rdb ${LOCAL_BACKUP_DIR}/redis/ ## for multiple instances : # for instance in $(ls -d /var/lib/redis-*); do # name=$(basename $instance) From 31fb33adc4571d97fddcaa074c6db4279b0f15dc Mon Sep 17 00:00:00 2001 From: Eric Morino Date: Tue, 22 Jun 2021 15:36:12 +0200 Subject: [PATCH 04/13] Add compressed PostgreSQL dump for each databases --- zzz_evobackup | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zzz_evobackup b/zzz_evobackup index 45c636d..92b5720 100755 --- a/zzz_evobackup +++ b/zzz_evobackup @@ -212,6 +212,7 @@ if [ "${LOCAL_TASKS}" = "1" ]; then ## Purge previous dumps # rm ${LOCAL_BACKUP_DIR}/pg.*.gz # rm ${LOCAL_BACKUP_DIR}/pg-backup.tar + # rm ${LOCAL_BACKUP_DIR}/postgresql/* ## example with pg_dumpall (warning: you need space in ~postgres) # su - postgres -c "pg_dumpall > ~/pg.dump.bak" # mv ~postgres/pg.dump.bak ${LOCAL_BACKUP_DIR}/ @@ -226,6 +227,13 @@ if [ "${LOCAL_TASKS}" = "1" ]; then ## example with only TABLE1 and TABLE2 from MYBASE # pg_dump -p 5432 -h 127.0.0.1 -U USER --clean -F t --inserts -f ${LOCAL_BACKUP_DIR}/pg-backup.tar -T 'TABLE1' -T 'TABLE2' MYBASE + ## example with compressed PostgreSQL dump for each databases + # mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/postgresql + # chown postgres:postgres ${LOCAL_BACKUP_DIR}/postgresql + # dbs=$(sudo -u postgres psql -U postgres -lt | awk -F\| '{print $1}' |grep -v template*) + # + # for databases in $dbs ; do sudo -u postgres /usr/bin/pg_dump --create -s -U postgres -d $databases | gzip --best -c > ${LOCAL_BACKUP_DIR}/postgresql/$databases.sql.gz ; done + ## MongoDB ## don't forget to create use with read-only access From a50991226c1431eb84c343baaa8c228197c1f341 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Mon, 28 Jun 2021 21:37:05 +0200 Subject: [PATCH 05/13] =?UTF-8?q?bkctld-rename:=20rename=20a=20jail=20and?= =?UTF-8?q?=20all=20its=20incs=20and=20configuration=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ bkctld | 10 +++++++ lib/bkctld-rename | 71 +++++++++++++++++++++++++++++++++++++++++++++++ test/main.bats | 16 ++++++++++- 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 lib/bkctld-rename diff --git a/CHANGELOG.md b/CHANGELOG.md index b2f2728..c2d6160 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* bkctld-rename: rename a jail and all its incs and configuration… + ### Changed ### Deprecated diff --git a/bkctld b/bkctld index 01dae84..373dbbd 100755 --- a/bkctld +++ b/bkctld @@ -156,6 +156,16 @@ case "${subcommand}" in done echo "finish" ;; + "rename") + jail_name="${2:-}" + new_jail_name="${3:-}" + if [ -z "${jail_name}" ] || [ -z "${new_jail_name}" ]; then + show_help + exit 1 + else + "${LIBDIR}/bkctld-${subcommand}" "${jail_name}" "${new_jail_name}" + fi + ;; *) show_help exit 1 diff --git a/lib/bkctld-rename b/lib/bkctld-rename new file mode 100755 index 0000000..73f7a8a --- /dev/null +++ b/lib/bkctld-rename @@ -0,0 +1,71 @@ +#!/bin/sh +# +# Description: Rename a jail +# Usage: rename +# Return codes: +# * 1: error +# + +# shellcheck source=./includes +LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes" + +jail_name="${1:?}" +new_jail_name="${2:?}" +if [ -z "${jail_name}" ] || [ -z "${new_jail_name}" ]; then + show_help && exit 1 +fi +jail_path=$(jail_path "${jail_name}") +incs_path=$(incs_path "${jail_name}") +jail_config_dir=$(jail_config_dir "${jail_name}") +legacy_config_file="${CONFDIR}/${jail_name}" + +test -d "${jail_path}" || error "${jail_name}: jail not found" 2 + +new_jail_path=$(jail_path "${new_jail_name}") +new_incs_path=$(incs_path "${new_jail_name}") +new_jail_config_dir=$(jail_config_dir "${new_jail_name}") +new_legacy_config_file="${CONFDIR}/${new_jail_name}" + +test -d "${new_jail_path}" && error "${new_jail_name}: jail already exists" 2 + +"${LIBDIR}/bkctld-is-on" "${jail_name}" 2>/dev/null +case "$?" in + 0) + jail_initial_status="on" + ;; + 100) + jail_initial_status="off" + ;; + *) + unset jail_initial_status + error "Error evaluating jail \`${jail_name}' state. bkctld-is-on exited with \`$?'" + ;; +esac + +test "${jail_initial_status}" = "on" && "${LIBDIR}/bkctld-stop" "${jail_name}" + +if dry_run; then + echo "[dry-run] rename ${jail_path} to ${new_jail_path}" + echo "[dry-run] rename ${incs_path} to ${new_incs_path}" +else + mv "${jail_path}" "${new_jail_path}" + mv "${incs_path}" "${new_incs_path}" +fi +if [ -d "${jail_config_dir}" ]; then + if dry_run; then + mv "${jail_config_dir}" "${new_jail_config_dir}" + else + echo "[dry-run] rename ${jail_config_dir} to ${new_jail_config_dir}" + fi +fi +if [ -f "${legacy_config_file}" ]; then + if dry_run; then + mv "${legacy_config_file}" "${new_legacy_config_file}" + else + echo "[dry-run] rename ${legacy_config_file} to ${new_legacy_config_file}" + fi +fi + +test "${jail_initial_status}" = "on" && "${LIBDIR}/bkctld-start" "${new_jail_name}" + +notice "Rename jail \`${jail_name}' to \`${new_jail_name}' : OK" \ No newline at end of file diff --git a/test/main.bats b/test/main.bats index 7d7e7bb..62867eb 100755 --- a/test/main.bats +++ b/test/main.bats @@ -61,6 +61,20 @@ load test_helper refute_equal "${pid_before}" "${pid_after}" } +@test "A jail should be able to be renamed" { + /usr/lib/bkctld/bkctld-start "${JAILNAME}" + new_name="${JAILNAME}-new" + # A started jail should report to be ON + run /usr/lib/bkctld/bkctld-rename "${JAILNAME}" "${new_name}" + assert_success + + run /usr/lib/bkctld/bkctld-is-on "${new_name}" + assert_success + + # change variable to new name,for teardown + JAILNAME="${new_name}" +} + @test "Status should return information" { run /usr/lib/bkctld/bkctld-status "${JAILNAME}" assert_success @@ -76,4 +90,4 @@ load test_helper # A stopped jail should not report to be ON run /usr/lib/bkctld/bkctld-is-on "${JAILNAME}" assert_failure -} +} \ No newline at end of file From d467690ff5a51ce5bc724b40da05c6e86eb45b9a Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Mon, 28 Jun 2021 21:44:48 +0200 Subject: [PATCH 06/13] Reset firewall for new jail name --- lib/bkctld-rename | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/bkctld-rename b/lib/bkctld-rename index 73f7a8a..fc44f91 100755 --- a/lib/bkctld-rename +++ b/lib/bkctld-rename @@ -65,6 +65,8 @@ if [ -f "${legacy_config_file}" ]; then echo "[dry-run] rename ${legacy_config_file} to ${new_legacy_config_file}" fi fi +# Reset firewall for new jail name +"${LIBDIR}/bkctld-firewall" "${new_jail_name}" test "${jail_initial_status}" = "on" && "${LIBDIR}/bkctld-start" "${new_jail_name}" From 134faf3e47d97ee15d44176e653a8af2f16c6742 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 29 Jun 2021 07:44:38 +0200 Subject: [PATCH 07/13] bkctld-archive: archive a jail --- CHANGELOG.md | 1 + bkctld | 2 +- bkctld.conf | 1 + lib/bkctld-archive | 51 ++++++++++++++++++++++++++++++++++++++++++++++ lib/includes | 7 +++++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 lib/bkctld-archive diff --git a/CHANGELOG.md b/CHANGELOG.md index c2d6160..35c88e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* bkctld-archive: archive a jail * bkctld-rename: rename a jail and all its incs and configuration… ### Changed diff --git a/bkctld b/bkctld index 373dbbd..1c37ceb 100755 --- a/bkctld +++ b/bkctld @@ -101,7 +101,7 @@ case "${subcommand}" in "${LIBDIR}/bkctld-${subcommand}" "${jail_name}" "${option}" fi ;; - "start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove" | "firewall" | "upgrade-config") + "start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove" | "firewall" | "upgrade-config" | "archive") jail_name="${2:-}" if [ "${jail_name}" = "all" ]; then for jail in $("${LIBDIR}/bkctld-list"); do diff --git a/bkctld.conf b/bkctld.conf index d6307a7..ea81ceb 100644 --- a/bkctld.conf +++ b/bkctld.conf @@ -14,3 +14,4 @@ #FIREWALL_RULES='' #LOGLEVEL=6 #NODE='' +#ARCHIVESDIR='/backup/archives' diff --git a/lib/bkctld-archive b/lib/bkctld-archive new file mode 100755 index 0000000..abf179d --- /dev/null +++ b/lib/bkctld-archive @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Description: Archive jail and all dated copies (incs) +# Usage: archive |all +# Return codes: +# * 101 : jail archival aborted +# + +# shellcheck source=./includes +LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes" + +jail_name="${1:?}" +if [ -z "${jail_name}" ]; then + show_help && exit 1 +fi +jail_path=$(jail_path "${jail_name}") + +test -d "${jail_path}" || error "${jail_name}: jail not found" 2 + +archive_jail_path=$(archive_path "${jail_name}") + +test -d "${archive_jail_path}" && error "${jail_name}: archive already exists" 2 + +if [ "${FORCE}" != "1" ]; then + answer="" + while :; do + printf "> Are you sure you want to archive jail \`%s'? [Y,n,?] " "${jail_name}" + read -r answer + case $answer in + [Yy]|"" ) + break + ;; + [Nn] ) + tty -s && echo "Abort." >&2 + exit 101 + ;; + * ) + printf "y - yes, execute actions and exit\n" + printf "n - no, don't execute actions and exit\n" + printf "? - print this help\n" + ;; + esac + done +fi + +"${LIBDIR}/bkctld-is-on" "${jail_name}" && "${LIBDIR}/bkctld-stop" "${jail_name}" + +mkdir -p "$(dirname "${archive_jail_path}")" +mv "${jail_path}" "${archive_jail_path}" + +notice "Archive jail \`${jail_name}' : OK" diff --git a/lib/includes b/lib/includes index f2aae3c..a2eb76b 100755 --- a/lib/includes +++ b/lib/includes @@ -17,6 +17,7 @@ INCDIR="${INCDIR:-${BACKUP_PARTITION}/incs}" TPLDIR="${TPLDIR:-/usr/share/bkctld}" LOCALTPLDIR="${LOCALTPLDIR:-/usr/local/share/bkctld}" LOCKDIR="${LOCKDIR:-/run/lock/bkctld}" +ARCHIVESDIR="${ARCHIVESDIR:-${BACKUP_PARTITION}/archives}" INDEX_DIR="${INDEX_DIR:-${BACKUP_PARTITION}/index}" IDX_FILE="${IDX_FILE:-${INDEX_DIR}/bkctld-jails.idx}" SSHD_PID="${SSHD_PID:-/run/sshd.pid}" @@ -157,6 +158,12 @@ jail_incs_policy_file() { echo "${jail_config_dir}/incs_policy" } +# Returns the complete path of an archived jail +archive_path() { + jail_name=${1:?} + + echo "${ARCHIVESDIR}/${jail_name}" +} # Returns the path of incs for a jail incs_path() { jail_name=${1:?} From 49fff6e85d863a55e933e5f1edd745617d648856 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 29 Jun 2021 07:53:38 +0200 Subject: [PATCH 08/13] bkctld-rename: reset firewall rules and fix logic error --- lib/bkctld-rename | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/bkctld-rename b/lib/bkctld-rename index fc44f91..2147a13 100755 --- a/lib/bkctld-rename +++ b/lib/bkctld-rename @@ -46,16 +46,23 @@ test "${jail_initial_status}" = "on" && "${LIBDIR}/bkctld-stop" "${jail_name}" if dry_run; then echo "[dry-run] rename ${jail_path} to ${new_jail_path}" - echo "[dry-run] rename ${incs_path} to ${new_incs_path}" else mv "${jail_path}" "${new_jail_path}" - mv "${incs_path}" "${new_incs_path}" +fi +if dry_run; then + if [ -d "${incs_path}" ]; then + echo "[dry-run] rename ${incs_path} to ${new_incs_path}" + fi +else + if [ -d "${incs_path}" ]; then + mv "${incs_path}" "${new_incs_path}" + fi fi if [ -d "${jail_config_dir}" ]; then if dry_run; then - mv "${jail_config_dir}" "${new_jail_config_dir}" - else echo "[dry-run] rename ${jail_config_dir} to ${new_jail_config_dir}" + else + mv "${jail_config_dir}" "${new_jail_config_dir}" fi fi if [ -f "${legacy_config_file}" ]; then @@ -66,6 +73,7 @@ if [ -f "${legacy_config_file}" ]; then fi fi # Reset firewall for new jail name +"${LIBDIR}/bkctld-firewall" "${jail_name}" "${LIBDIR}/bkctld-firewall" "${new_jail_name}" test "${jail_initial_status}" = "on" && "${LIBDIR}/bkctld-start" "${new_jail_name}" From b1b4d8b19f8ea44417e0a6293efe290f9ea41088 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 29 Jun 2021 07:57:44 +0200 Subject: [PATCH 09/13] No date/process in stdout/stderr Don't treat stdout/stderr as a logging facility --- lib/includes | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/includes b/lib/includes index a2eb76b..c5727d4 100755 --- a/lib/includes +++ b/lib/includes @@ -71,7 +71,7 @@ process_name() { debug() { msg="${1:-$(cat /dev/stdin)}" if [ "${LOGLEVEL}" -ge 7 ]; then - echo "$(log_date) DEBUG $(process_name) ${msg}" + echo "${msg}" logger -t bkctld -p daemon.debug "$(process_name) ${msg}" fi } @@ -79,22 +79,22 @@ debug() { info() { msg="${1:-$(cat /dev/stdin)}" if [ "${LOGLEVEL}" -ge 6 ]; then - tty -s && echo "$(log_date) INFO $(process_name) ${msg}" + tty -s && echo "${msg}" logger -t bkctld -p daemon.info "$(process_name) ${msg}" fi } notice() { msg="${1:-$(cat /dev/stdin)}" - tty -s && echo "$(log_date) NOTICE $(process_name) ${msg}" + tty -s && echo "${msg}" [ "${LOGLEVEL}" -ge 5 ] && logger -t bkctld -p daemon.notice "$(process_name) ${msg}" } warning() { msg="${1:-$(cat /dev/stdin)}" - tty -s && echo "$(log_date) WARNING $(process_name) ${msg}" >&2 + tty -s && echo "${msg}" >&2 if [ "${LOGLEVEL}" -ge 4 ]; then - tty -s || echo "$(log_date) WARNING $(process_name) ${msg}" >&2 + tty -s || echo "${msg}" >&2 logger -t bkctld -p daemon.warning "$(process_name) ${msg}" fi } @@ -105,9 +105,9 @@ warning() { error() { msg="${1:-$(cat /dev/stdin)}" rc="${2:-1}" - tty -s && echo "$(log_date) ERROR $(process_name) ${msg}" >&2 + tty -s && echo "${msg}" >&2 if [ "${LOGLEVEL}" -ge 5 ]; then - tty -s || echo "$(log_date) ERROR $(process_name) ${msg}" >&2 + tty -s || echo "${msg}" >&2 logger -t bkctld -p daemon.error "$(process_name) ${msg}" fi exit ${rc} From c38ec8901085ddf0158494565361f882b5ea76cc Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 29 Jun 2021 17:18:30 +0200 Subject: [PATCH 10/13] Add tests for bkctld-archive --- test/main.bats | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/main.bats b/test/main.bats index 62867eb..90677a1 100755 --- a/test/main.bats +++ b/test/main.bats @@ -75,6 +75,26 @@ load test_helper JAILNAME="${new_name}" } +@test "A jail should be able to be archived" { + /usr/lib/bkctld/bkctld-start "${JAILNAME}" + # A started jail should report to be ON + run /usr/lib/bkctld/bkctld-is-on "${JAILNAME}" + assert_success + + run /usr/lib/bkctld/bkctld-archive "${JAILNAME}" + assert_success + + # A started jail should report to be OFF + run /usr/lib/bkctld/bkctld-is-on "${JAILNAME}" + assert_failure + + run test -d "${JAILPATH}" + assert_failure + + run test -d "/backup/archives/${JAILNAME}" + assert_success +} + @test "Status should return information" { run /usr/lib/bkctld/bkctld-status "${JAILNAME}" assert_success From d8e1ce9fb186d18ea44240dd1474932afe8ff6a5 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 29 Jun 2021 17:19:02 +0200 Subject: [PATCH 11/13] bkctld-remove: force mode bypass inexisting jail --- lib/bkctld-remove | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/bkctld-remove b/lib/bkctld-remove index 94d6b19..def4e74 100755 --- a/lib/bkctld-remove +++ b/lib/bkctld-remove @@ -16,7 +16,14 @@ fi jail_path=$(jail_path "${jail_name}") incs_path=$(incs_path "${jail_name}") -test -d "${jail_path}" || error "${jail_name}: jail not found" 2 +if ! test -d "${jail_path}"; then + if [ "${FORCE}" = "1" ]; then + warning "${jail_name}: jail not found (ignore in FORCE mode)" + exit 0 + else + error "${jail_name}: jail not found" 2 + fi +fi if [ "${FORCE}" != "1" ]; then answer="" From 9e1d8636ff621fa327b3a2d68d384bb322d95ca6 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 29 Jun 2021 17:19:40 +0200 Subject: [PATCH 12/13] update copyright --- lib/includes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/includes b/lib/includes index c5727d4..309a27f 100755 --- a/lib/includes +++ b/lib/includes @@ -34,7 +34,7 @@ show_version() { cat <, +Copyright 2004-2021 Evolix , Victor Laborie , Jérémy Lecour and others. From ec4502ef9bdf2e5fc52375a645388b25c3da587d Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 29 Jun 2021 17:19:51 +0200 Subject: [PATCH 13/13] Release 2.10.0 --- CHANGELOG.md | 13 ++++++++++--- lib/includes | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c88e2..992fb70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* bkctld-archive: archive a jail -* bkctld-rename: rename a jail and all its incs and configuration… - ### Changed ### Deprecated @@ -21,6 +18,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security +## [2.10.0] - 2021-06-29 + +### Added + +* bkctld-archive: archive a jail +* bkctld-rename: rename a jail and all its incs and configuration… + +### Removed + +* Do not print out date, log level and process name on stdout/stderr ## [2.9.0] - 2021-02-22 ### Added diff --git a/lib/includes b/lib/includes index 309a27f..93d83ba 100755 --- a/lib/includes +++ b/lib/includes @@ -6,7 +6,7 @@ [ -f /etc/default/bkctld ] && . /etc/default/bkctld -VERSION="2.9.0" +VERSION="2.10.0" LIBDIR=${LIBDIR:-/usr/lib/bkctld} CONFDIR="${CONFDIR:-/etc/evobackup}"