Introducing evobackupctl
This commit is contained in:
parent
ceb12254be
commit
98bfc5d840
|
@ -1,31 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Change this to wherever you install the libraries
|
||||
LIBDIR="/usr/local/lib/evobackup"
|
||||
|
||||
source "${LIBDIR}/main.sh"
|
||||
|
||||
# Parse options, based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
|
||||
while :; do
|
||||
case ${1:-''} in
|
||||
-V|--version)
|
||||
show_version
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
# End of all options.
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-?*|[[:alnum:]]*)
|
||||
# ignore unknown options
|
||||
log_error "unknown option '${1}' (ignored)"
|
||||
;;
|
||||
*)
|
||||
# Default case: If no more options then break out of the loop.
|
||||
break
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
120
client/bin/evobackupctl
Normal file
120
client/bin/evobackupctl
Normal file
|
@ -0,0 +1,120 @@
|
|||
#!/bin/bash
|
||||
|
||||
readonly VERSION="23.12-pre"
|
||||
|
||||
# shellcheck disable=SC2155
|
||||
readonly PROGNAME=$(basename "${0}")
|
||||
# shellcheck disable=SC2155
|
||||
readonly PROGDIR=$(readlink -m "$(dirname "${0}")")
|
||||
# shellcheck disable=SC2124
|
||||
readonly ARGS=$@
|
||||
|
||||
# Change this to wherever you install the libraries
|
||||
readonly LIBDIR="/usr/local/lib/evobackup"
|
||||
|
||||
show_version() {
|
||||
cat <<END
|
||||
${PROGNAME} version ${VERSION}
|
||||
|
||||
Copyright 2023 Evolix <info@evolix.fr>,
|
||||
Gregory Colpart <reg@evolix.fr>,
|
||||
Romain Dessort <rdessort@evolix.fr>,
|
||||
Benoit Série <bserie@evolix.fr>,
|
||||
Tristan Pilat <tpilat@evolix.fr>,
|
||||
Victor Laborie <vlaborie@evolix.fr>,
|
||||
Jérémy Lecour <jlecour@evolix.fr>
|
||||
and others.
|
||||
|
||||
${PROGNAME} comes with ABSOLUTELY NO WARRANTY. This is free software,
|
||||
and you are welcome to redistribute it under certain conditions.
|
||||
See the GNU General Public License v3.0 for details.
|
||||
END
|
||||
}
|
||||
show_help() {
|
||||
cat <<END
|
||||
${PROGNAME} helps managing evobackup scripts
|
||||
|
||||
Options
|
||||
-h, --help print this message and exit
|
||||
-V, --version print version and exit
|
||||
--copy-template=PATH copy the backup template to PATH
|
||||
END
|
||||
}
|
||||
|
||||
copy_template() {
|
||||
dest_path=${1}
|
||||
dest_dir="$(dirname "${dest_path}")"
|
||||
|
||||
if [ -e "${dest_path}" ]; then
|
||||
printf "Path for new evobackup script '%s' already exists.\n" "${dest_path}" >&2
|
||||
exit 1
|
||||
elif [ ! -e "${dest_dir}" ]; then
|
||||
printf "Parent directory '%s' doesn't exist. Create it first.\n" "${dest_dir}" >&2
|
||||
exit 1
|
||||
else
|
||||
if cp "${LIBDIR}/zzz_evobackup.sh" "${dest_path}"; then
|
||||
chmod 750 "${dest_path}"
|
||||
|
||||
sed -i "s|@COMMAND@|${PROGDIR}/${PROGNAME} ${ARGS}|" "${dest_path}"
|
||||
sed -i "s|@DATE@|$(date --iso-8601=seconds)|" "${dest_path}"
|
||||
sed -i "s|@VERSION@|${VERSION}|" "${dest_path}"
|
||||
|
||||
printf "New evobackup script has been saved to '%s'.\n" "${dest_path}"
|
||||
printf "Remember to customize it (mail notifications, backup servers…).\n"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# Parse options, based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
|
||||
while :; do
|
||||
case ${1:-''} in
|
||||
-V|--version)
|
||||
show_version
|
||||
exit 0
|
||||
;;
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--copy-template)
|
||||
# copy-template option, with value separated by space
|
||||
if [ -n "$2" ]; then
|
||||
copy_template "${2}"
|
||||
shift
|
||||
else
|
||||
printf "'%s' requires a non-empty option argument.\n" "--copy-template" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--copy-template=?*)
|
||||
# copy-template option, with value separated by =
|
||||
copy_template "${1#*=}"
|
||||
;;
|
||||
--copy-template=)
|
||||
# copy-template option, without value
|
||||
printf "'%s' requires a non-empty option argument.\n" "--copy-template" >&2
|
||||
exit 1
|
||||
;;
|
||||
--)
|
||||
# End of all options.
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-?*|[[:alnum:]]*)
|
||||
# ignore unknown options
|
||||
printf "unknown option '%s'.\n" "${1}" >&2
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
# Default case: If no more options then break out of the loop.
|
||||
break
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
main ${ARGS}
|
|
@ -1,56 +0,0 @@
|
|||
###
|
||||
# ansible-playbook deploy-evobackup-beta.yml -K --diff -l HOSTNAME --check
|
||||
#
|
||||
---
|
||||
|
||||
- name: Deploy a beta version of evobackup
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
become: true
|
||||
|
||||
vars:
|
||||
evobackup_script_path: /etc/cron.daily/zzz_evobackup_beta
|
||||
evobackup_mail: alert4@evolix.net
|
||||
evobackup_libdir: "/usr/local/lib/evobackup"
|
||||
|
||||
tasks:
|
||||
- name: LIBDIR is present
|
||||
file:
|
||||
path: "{{ evobackup_libdir }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
state: directory
|
||||
|
||||
- name: libraries are installed
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ evobackup_libdir }}/"
|
||||
remote_src: false
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
force: true
|
||||
loop: "{{ lookup('fileglob', 'lib/*.sh', wantlist=True) }}"
|
||||
|
||||
- name: script is present
|
||||
copy:
|
||||
src: zzz_evobackup
|
||||
dest: "{{ evobackup_script_path }}"
|
||||
remote_src: false
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
force: false
|
||||
|
||||
- name: Email is customized
|
||||
replace:
|
||||
dest: "{{ evobackup_script_path }}"
|
||||
regexp: "^MAIL=.*"
|
||||
replace: "MAIL={{ evobackup_mail }}"
|
||||
|
||||
- name: LIBDIR is customized
|
||||
replace:
|
||||
dest: "{{ evobackup_script_path }}"
|
||||
regexp: "^LIBDIR=.*"
|
||||
replace: "LIBDIR=\"{{ evobackup_libdir }}\""
|
|
@ -1,8 +1,6 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2034,SC2317
|
||||
|
||||
readonly VERSION="23.07-pre"
|
||||
|
||||
# set all programs to C language (english)
|
||||
export LC_ALL=C
|
||||
|
||||
|
@ -18,25 +16,6 @@ source "${LIBDIR}/dump-mysql.sh"
|
|||
source "${LIBDIR}/dump-postgresql.sh"
|
||||
source "${LIBDIR}/dump-misc.sh"
|
||||
|
||||
show_version() {
|
||||
cat <<END
|
||||
evobackup version ${VERSION}
|
||||
|
||||
Copyright 2023 Evolix <info@evolix.fr>,
|
||||
Gregory Colpart <reg@evolix.fr>,
|
||||
Romain Dessort <rdessort@evolix.fr>,
|
||||
Benoit Série <bserie@evolix.fr>,
|
||||
Tristan Pilat <tpilat@evolix.fr>,
|
||||
Victor Laborie <vlaborie@evolix.fr>,
|
||||
Jérémy Lecour <jlecour@evolix.fr>
|
||||
and others.
|
||||
|
||||
evobackup comes with ABSOLUTELY NO WARRANTY. This is free software,
|
||||
and you are welcome to redistribute it under certain conditions.
|
||||
See the GNU General Public License v3.0 for details.
|
||||
END
|
||||
}
|
||||
|
||||
# Called from main, it is wrapping the local_tasks function defined in the real script
|
||||
local_tasks_wrapper() {
|
||||
log "START LOCAL_TASKS"
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
#
|
||||
# Evobackup client
|
||||
# See https://gitea.evolix.org/evolix/evobackup
|
||||
#
|
||||
# This is a generated backup script made by:
|
||||
# command: @COMMAND@
|
||||
# version: @VERSION@
|
||||
# date: @DATE@
|
||||
|
||||
#######################################################################
|
||||
#
|
Loading…
Reference in a new issue