new subcommands with backward compatibility
This commit is contained in:
parent
5020ca4bfd
commit
7d4de721ea
105
bkctld
105
bkctld
|
@ -51,6 +51,7 @@ while :; do
|
|||
exit 0
|
||||
;;
|
||||
-f|--force)
|
||||
# shellcheck disable=SC2034
|
||||
FORCE=1
|
||||
;;
|
||||
*)
|
||||
|
@ -64,11 +65,34 @@ done
|
|||
|
||||
subcommand="${1:-}"
|
||||
case "${subcommand}" in
|
||||
"inc" | "rm" | "check-jails" | "check-setup" | "stats" | "list")
|
||||
"${LIBDIR}/bkctld-${subcommand}"
|
||||
"list")
|
||||
"${LIBDIR}/bkctld-list"
|
||||
;;
|
||||
"stats")
|
||||
"${LIBDIR}/bkctld-stats"
|
||||
;;
|
||||
"incs-create")
|
||||
"${LIBDIR}/bkctld-incs-create"
|
||||
;;
|
||||
"inc")
|
||||
deprecated_cmd "bkctld inc", "bkctld incs-create"
|
||||
"${LIBDIR}/bkctld-incs-create"
|
||||
;;
|
||||
"incs-prune")
|
||||
"${LIBDIR}/bkctld-incs-prune"
|
||||
;;
|
||||
"rm")
|
||||
deprecated_cmd "bkctld rm", "bkctld incs-prune"
|
||||
"${LIBDIR}/bkctld-incs-prune"
|
||||
;;
|
||||
"check")
|
||||
# backward compatibility
|
||||
deprecated_cmd "bkctld check", "bkctld jails-check"
|
||||
"${LIBDIR}/bkctld-check-jails"
|
||||
;;
|
||||
"check-setup")
|
||||
"${LIBDIR}/bkctld-check-setup"
|
||||
;;
|
||||
"check-jails")
|
||||
"${LIBDIR}/bkctld-check-jails"
|
||||
;;
|
||||
"check-incs")
|
||||
|
@ -91,17 +115,78 @@ case "${subcommand}" in
|
|||
"${LIBDIR}/bkctld-${subcommand}" "${jail_name}"
|
||||
fi
|
||||
;;
|
||||
"key" | "port" | "ip")
|
||||
"ip-add")
|
||||
jail_name="${2:-}"
|
||||
option="${3:-}"
|
||||
if [ "${jail_name}" = "all" ] || [ -z "${jail_name}" ]; then
|
||||
show_help
|
||||
exit 1
|
||||
else
|
||||
"${LIBDIR}/bkctld-${subcommand}" "${jail_name}" "${option}"
|
||||
"${LIBDIR}/bkctld-ip" "${jail_name}" "${option}"
|
||||
;;
|
||||
"ip-replace")
|
||||
jail_name="${2:-}"
|
||||
option="${3:-}"
|
||||
"${LIBDIR}/bkctld-ip" "${jail_name}" "0.0.0.0/0"
|
||||
if [ -n "${option}" ]; then
|
||||
"${LIBDIR}/bkctld-ip" "${jail_name}" "${option}"
|
||||
fi
|
||||
;;
|
||||
"start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove" | "firewall" | "upgrade-config")
|
||||
"ip-list")
|
||||
jail_name="${2:-}"
|
||||
"${LIBDIR}/bkctld-ip" "${jail_name}"
|
||||
;;
|
||||
"ip")
|
||||
jail_name="${2:-}"
|
||||
option="${3:-}"
|
||||
if [ -n "${option}" ]; then
|
||||
if [ "${option}" = "0.0.0.0/0" ] || [ "${option}" = "all" ]; then
|
||||
deprecated_cmd "bkctld ip ${jail_name} ${option}", "bkctld ip-replace ${jail_name}"
|
||||
else
|
||||
deprecated_cmd "bkctld ip ${jail_name} ${option}", "bkctld ip-add ${jail_name} ${option}"
|
||||
fi
|
||||
"${LIBDIR}/bkctld-ip" "${jail_name}" "${option}"
|
||||
else
|
||||
deprecated_cmd "bkctld ip ${jail_name}", "bkctld ip-list ${jail_name}"
|
||||
"${LIBDIR}/bkctld-ip" "${jail_name}"
|
||||
fi
|
||||
;;
|
||||
"key-list")
|
||||
jail_name="${2:-}"
|
||||
"${LIBDIR}/bkctld-key" "${jail_name}"
|
||||
;;
|
||||
"key-replace")
|
||||
jail_name="${2:-}"
|
||||
option="${3:-}"
|
||||
"${LIBDIR}/bkctld-key" "${jail_name}" "${option}"
|
||||
;;
|
||||
"key-add")
|
||||
error "\`bkctld key-add' command is not available yet!"
|
||||
;;
|
||||
"key")
|
||||
jail_name="${2:-}"
|
||||
option="${3:-}"
|
||||
if [ -n "${option}" ]; then
|
||||
deprecated_cmd "bkctld key ${jail_name} ${option}", "bkctld key-replace ${jail_name} ${option}"
|
||||
"${LIBDIR}/bkctld-key" "${jail_name}" "${option}"
|
||||
else
|
||||
deprecated_cmd "bkctld key ${jail_name}", "bkctld key-list ${jail_name}"
|
||||
"${LIBDIR}/bkctld-key" "${jail_name}"
|
||||
fi
|
||||
;;
|
||||
"port")
|
||||
jail_name="${2:-}"
|
||||
option="${3:-}"
|
||||
"${LIBDIR}/bkctld-port" "${jail_name}" "${option}"
|
||||
;;
|
||||
"archive")
|
||||
error "\`bkctld archive' command is not available yet!"
|
||||
;;
|
||||
"remove")
|
||||
jail_name="${2:-}"
|
||||
if [ "${jail_name}" = "all" ]; then
|
||||
error "\`bkctld remove all' is too dangerous."
|
||||
else
|
||||
"${LIBDIR}/bkctld-remove" "${jail_name}"
|
||||
fi
|
||||
;;
|
||||
"start" | "stop" | "reload" | "restart" | "sync" | "update" | "firewall" | "upgrade-config")
|
||||
jail_name="${2:-}"
|
||||
if [ "${jail_name}" = "all" ]; then
|
||||
for jail in $("${LIBDIR}/bkctld-list"); do
|
||||
|
|
4
bkctld.8
4
bkctld.8
|
@ -124,8 +124,8 @@ in
|
|||
He can then create the jail:
|
||||
.Bd -literal -offset indent
|
||||
# bkctld init CLIENT_HOST_NAME
|
||||
# bkctld key CLIENT_HOST_NAME /root/CLIENT_HOST_NAME.pub
|
||||
# bkctld ip CLIENT_HOST_NAME CLIENT_IP_ADDRESS
|
||||
# bkctld key-add CLIENT_HOST_NAME /root/CLIENT_HOST_NAME.pub
|
||||
# bkctld ip-add CLIENT_HOST_NAME CLIENT_IP_ADDRESS
|
||||
# bkctld start CLIENT_HOST_NAME
|
||||
# bkctld status CLIENT_HOST_NAME
|
||||
.Ed
|
||||
|
|
|
@ -20,7 +20,7 @@ backup for which the rules it contains must apply.
|
|||
|
||||
The rules it defines decide which incremental backups are kept when running
|
||||
|
||||
# bkctld rm
|
||||
# bkctld incs-prune
|
||||
|
||||
Each line defines a single rule.
|
||||
The first part of the rule describes when the backup was taken,
|
||||
|
|
|
@ -61,11 +61,11 @@ Edit the root crontab
|
|||
~~~
|
||||
# $editor /etc/cron.d/bkctld
|
||||
+ MAILTO=alert4@evolix.net
|
||||
+ 30 11 * * * root /usr/sbin/bkctld inc && /usr/sbin/bkctld rm
|
||||
+ 30 11 * * * root /usr/sbin/bkctld incs-create && /usr/sbin/bkctld incs-prune
|
||||
+ 30 23 * * * root /usr/share/scripts/check-incs.sh 1> /dev/null
|
||||
~~~
|
||||
|
||||
## Notes
|
||||
If you want mutiples backups in a day (1 per hour maximum) you can
|
||||
run `bkctld inc` multiples times, if you want to keep incremental
|
||||
backups **for ever**, just don't run `bkctld rm`.
|
||||
run `bkctld incs-create` multiples times, if you want to keep incremental
|
||||
backups **for ever**, just don't run `bkctld incs-prune`.
|
||||
|
|
|
@ -156,8 +156,8 @@ the backup server administrator will need:
|
|||
He can then create the jail:
|
||||
|
||||
# bkctld init <JAIL_NAME>
|
||||
# bkctld key <JAIL_NAME> /root/<JAIL_NAME>.pub
|
||||
# bkctld ip <JAIL_NAME> <IP_OR_CIDR>
|
||||
# bkctld key-add <JAIL_NAME> /root/<JAIL_NAME>.pub
|
||||
# bkctld ip-add <JAIL_NAME> <IP_OR_CIDR>
|
||||
# bkctld start <JAIL_NAME>
|
||||
# bkctld status <JAIL_NAME>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ backup for which the rules it contains must apply.
|
|||
.Pp
|
||||
The rules it defines decide which incremental backups are kept when running
|
||||
.Bd -literal -offset indent
|
||||
# bkctld rm
|
||||
# bkctld incs-prune
|
||||
.Ed
|
||||
.Pp
|
||||
Each line defines a single rule.
|
||||
|
|
|
@ -111,6 +111,12 @@ error() {
|
|||
fi
|
||||
exit ${rc}
|
||||
}
|
||||
deprecated_cmd() {
|
||||
old=${1:?}
|
||||
new=${2:?}
|
||||
|
||||
warning "\`${old}' is deprecated, use \`${new}' instead"
|
||||
}
|
||||
|
||||
dry_run() {
|
||||
test "$DRY_RUN" = "1"
|
||||
|
|
|
@ -11,7 +11,7 @@ load test_helper
|
|||
}
|
||||
|
||||
@test "Normal inc creation" {
|
||||
/usr/lib/bkctld/bkctld-inc
|
||||
/usr/lib/bkctld/bkctld-incs-create
|
||||
|
||||
if is_btrfs "/backup"; then
|
||||
# On a btrfs filesystem, the inc should be a btrfs volume
|
||||
|
@ -27,7 +27,7 @@ load test_helper
|
|||
@test "Normal inc creation (with old incs policy)" {
|
||||
mv "${CONFDIR}/${JAILNAME}.d/incs_policy" "${CONFDIR}/${JAILNAME}"
|
||||
|
||||
/usr/lib/bkctld/bkctld-inc
|
||||
/usr/lib/bkctld/bkctld-incs-create
|
||||
|
||||
if is_btrfs "/backup"; then
|
||||
# On a btrfs filesystem, the inc should be a btrfs volume
|
||||
|
@ -46,7 +46,7 @@ load test_helper
|
|||
# … and old file
|
||||
rm -f "${CONFDIR}/${JAILNAME}"
|
||||
|
||||
/usr/lib/bkctld/bkctld-inc
|
||||
/usr/lib/bkctld/bkctld-incs-create
|
||||
|
||||
run test -d "${INCSPATH}/${INC_NAME}"
|
||||
assert_failure
|
||||
|
@ -60,8 +60,8 @@ load test_helper
|
|||
recent_inc_path="${INCSPATH}/${INC_NAME}"
|
||||
|
||||
# Create the inc, then run 'rm'
|
||||
/usr/lib/bkctld/bkctld-inc
|
||||
/usr/lib/bkctld/bkctld-rm
|
||||
/usr/lib/bkctld/bkctld-incs-create
|
||||
/usr/lib/bkctld/bkctld-incs-prune
|
||||
|
||||
# Recent inc should be present
|
||||
run test -d "${recent_inc_path}"
|
||||
|
@ -78,9 +78,9 @@ load test_helper
|
|||
older_inc_path="${INCSPATH}/${older_inc_name}"
|
||||
|
||||
# Create the inc, rename it to make it older, then run 'rm'
|
||||
/usr/lib/bkctld/bkctld-inc
|
||||
/usr/lib/bkctld/bkctld-incs-create
|
||||
mv "${recent_inc_path}" "${older_inc_path}"
|
||||
/usr/lib/bkctld/bkctld-rm
|
||||
/usr/lib/bkctld/bkctld-incs-prune
|
||||
|
||||
# Older inc should be removed
|
||||
run test -d "${older_inc_path}"
|
||||
|
|
Loading…
Reference in a new issue