Compare commits

...

99 commits

Author SHA1 Message Date
6a3ebe48e0 server > Introduce monitoring of inc creation time (#80)
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Reviewed-on: #80
2025-01-17 16:41:48 +01:00
636a5b6143
server: Delete inc timing files after 30days 2025-01-17 15:14:21 +01:00
ba5fab4852
server: Update CHANGELOG.md 2025-01-14 11:59:23 +01:00
0f7570fb87
server: bkctld-check-setup : Add a check to ensure inc creation time is bellow a given warning/critical threshold
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Time threshold being configured as :
INCTIME_WARNING > 12 hours by default
INCTIME_CRITICAL > 18 hours by default
2025-01-14 11:36:48 +01:00
a419e0262d
server: bkctld-check-setup : Warn when inc and rm are running at the same time
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2025-01-14 10:39:23 +01:00
8147ba84ee
server: bkctld-check-setup - Check how many inc operations are running
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Ok if there's none or one
Critical if theres more than one
2025-01-14 10:32:28 +01:00
457a4ddcda
server: Measure and keep inc creation time
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
This add a new directory, called DATADIR, that is located by default
in /var/lib/bkctld
This directory will contain files time-inc_????-??-??-?? with a track of
elasped time for creating each inc (+ global time)
2025-01-14 10:03:06 +01:00
ab9327b8b2
server: bkctld-rm: Add Begining/end log message and invert logging priorities
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Progress messages are now notice
Start/stop messages are info
2025-01-10 12:41:49 +01:00
981b8978e3
server: bkctld-inc: Add Begining/end log message (with the inc name) and invert logging priorities
Progress messages are now notice
Start/stop messages are info
2025-01-10 12:41:12 +01:00
9344bef64c
server: Update munin plugin bkctld_rsyncs
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
it wasn't working now that we switched to systemd-nspawn
2025-01-10 12:09:47 +01:00
084d4a5211
server: update changelog 2025-01-10 12:07:41 +01:00
0ce0d4213d
server: update changelog 2025-01-10 11:56:20 +01:00
a42c196f75 Disable padding for the last column (#54)
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Reviewed-on: #54
2025-01-10 11:08:13 +01:00
49b9b763fb
Merge branch 'master' into bkctld_status_disable_last_column_padding
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2025-01-10 11:03:16 +01:00
82820115c5 Client - Release 25.01
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
gitea/evobackup/pipeline/tag This commit looks good
2025-01-07 17:32:01 +01:00
ac0c137c50 Update CHANGELOG 2025-01-07 17:29:58 +01:00
ead8c7b48a Fix compatibility with OpenBSD (#79)
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
- `readlink` : option "-m" does not exist on OpenBSD, option "-f" exists on both Debian and OpenBSD
- `SERVER_IP` : no reason not to first use curl on OpenBSD too
- `date` : option "--iso-8601=seconds" does not exist on OpenBSD (and "%:z" neither) ; "+%FT%T%z" works on both Debian and OpenBSD but we loose the ":" in "+01:00" for the time zone

Co-authored-by: Jeremy Lecour <jlecour@evolix.fr>
Reviewed-on: #79
Reviewed-by: Mathieu Trossevin <mtrossevin@noreply.gitea.evolix.org>
Co-authored-by: Jérémy Dubois <jdubois@evolix.fr>
Co-committed-by: Jérémy Dubois <jdubois@evolix.fr>
2025-01-07 14:38:44 +01:00
Eric Morino
1c09d6f8bb Add function for backup Linstor Database
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2025-01-03 16:16:13 +01:00
8c1a220ac3 Introducing munin-plugins for bkctld (#64)
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Introducing munin-plugins for bkctld :

* incs > Total number of incs (+ expexted total)
* jails > Number of jails & active jails
* rsync > Number of curently running rsyncs
* ops > Track time when bkctld is doing incs & rm operations

Co-authored-by: Jérémy Lecour <jlecour@noreply.gitea.evolix.org>
Reviewed-on: #64
Co-authored-by: Ludovic Poujol <lpoujol@evolix.fr>
Co-committed-by: Ludovic Poujol <lpoujol@evolix.fr>
2025-01-03 11:50:42 +01:00
179d383fb5
fix(dump_elasticsearch): Add an \n before HTTP status code
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Elasticsearch's API do not add end of lines at the end of it's
responses. This break the final `grep` making the script believe there
was an error.
2024-12-19 15:58:09 +01:00
bc0cc3d6a1
client: release 24.12
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
gitea/evobackup/pipeline/tag This commit looks good
2024-12-18 15:47:31 +01:00
7ea63f4665
client: the template defaults to full Evolix backup
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-12-18 15:45:47 +01:00
Gregory Colpart
58512e6897 Revert "add exclude for /var/lib/docker/volumes" : we want it after internal discussions
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
This reverts commit 3c0090954b.
2024-12-18 15:41:46 +01:00
Gregory Colpart
3c0090954b add exclude for /var/lib/docker/volumes
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-12-18 13:56:19 +01:00
Gregory Colpart
38a1b14c9a add fix to changelog
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-12-18 13:01:32 +01:00
Gregory Colpart
d93535578e ajouter 'lxc/*/rootfs/dev' en exclude
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-12-18 12:59:58 +01:00
1bd60a3595
update CHANGELOG
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
gitea/evobackup/pipeline/tag This commit looks good
2024-11-29 10:57:50 +01:00
96a342b67f
client Release 24.11
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-11-29 10:55:57 +01:00
825b392c4f
Fix redis backup 2024-11-29 10:54:40 +01:00
07bb14445e
dump_postgresql_per_base: look for correct variable to build connect options: look for correct variable to build connect options
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-11-06 16:36:03 +01:00
a791d752f0
dump_postgresql_per_base: return if postgresql directory is missing 2024-11-06 16:30:58 +01:00
a9d90fc937
dump_redis: clean backup directory only if the Redis instance is valid 2024-11-06 16:29:50 +01:00
ba17140cfc
dump_redis: do not delete entire backup directory
If no option is given, the function must not delete the parent backup directory.
The fix is to declare the variable as an empty array, instead of a blank string.
2024-11-06 16:29:12 +01:00
ec9e056ff7
server: release 24.10
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
gitea/evobackup/pipeline/tag This commit looks good
2024-10-10 15:08:09 +02:00
d606fac7b4
server: Update changelog
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-09-27 09:49:33 +02:00
eb88df4a21 Remove internal link
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-09-23 10:00:59 +02:00
Brice Waegeneire
218570ed6e bkcltd: rm hide over allocation message
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
See https://github.com/RsyncProject/rsync/issues/552#issuecomment-1840914895
2024-09-17 16:38:48 +02:00
0c674f2440
server: (wip) Update changelog
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-09-09 12:01:10 +02:00
55974e1a26
server: Update check-canary to raise a warning (instead of critical) when yesterday's date is found
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-09-09 09:52:24 +02:00
a52b09f8db
server: Add commented config directive in sshd config template for old clients
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Warning, this would still need to be manually applied to old jail configs
2024-09-03 12:00:36 +02:00
11960efbbf
server: convert-v2 > Add missing move to the /root directory & mount point cleanings
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
We need to keep that, as it contains the allowed ssh keys
And the proc/ & dev/ folder as mount points aren't need anymore
2024-09-03 10:56:30 +02:00
Eric Morino
7e1cb11a9e fix typo when call option_dump_slave in dump_options
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-08-30 10:49:27 +02:00
Eric Morino
6f864ccbb1 fix bash compare for --dump-slave 2024-08-30 10:45:51 +02:00
Eric Morino
2cec5a274f re-arranging options_dump_slave
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-08-30 10:04:16 +02:00
Eric Morino
c25c498820 Add variable connect_options for dump per base
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-08-29 10:59:43 +02:00
d44be2f567 Use systemd-nspawn instead of chroot (#74)
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
Reviewed-on: #74
2024-08-28 17:16:39 +02:00
7f5fe8effa server: bump version number
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-08-28 17:15:48 +02:00
e5adfc9a58 server: fix broken permissions on files 2024-08-28 17:15:48 +02:00
64337a67b3 server: Add update current debian versions for vagrantfile 2024-08-28 17:15:48 +02:00
77f8f90d20 server: Add dependencies in Vagrantfile 2024-08-28 17:15:48 +02:00
c31114adbf server: More linting with shellcheck 2024-08-28 17:15:48 +02:00
e16feaeb17 server: New test, ensuring the jail has a version file 2024-08-28 17:15:48 +02:00
d606432fb6 server: lint: more quotes 2024-08-28 17:15:48 +02:00
a733b21645 server: lint: more quottings 2024-08-28 17:15:48 +02:00
91b5f37bc3 server: lint: More quotes 2024-08-28 17:15:48 +02:00
69a24c2108 server: lint: more variable quotes 2024-08-28 17:15:48 +02:00
f64cc93c21 server: replace printf with echo -n 2024-08-28 17:15:48 +02:00
3af7691599 server: Lint, change confiditionals "! -n" with "-z" 2024-08-28 17:15:48 +02:00
f469a265ae server: remove odd backticks 2024-08-28 17:15:48 +02:00
b956bc89a5 server: Update test suite
-> Use systemctl show to fetch the jail pid
-> Use journalctl to grep in jail log
-> Adapt paths to fit the new directory structures
2024-08-28 17:15:48 +02:00
5ab6f310f7 server: Update check-canary to be in the right jail path
ie: /data instead of /var/backup
2024-08-28 17:15:48 +02:00
40bacca027 server: Remove typo in bkctld-reload 2024-08-28 17:15:48 +02:00
05690dcc2f server: bkctld-remove > Cleanup nspawn setup/config 2024-08-28 17:15:48 +02:00
e2531d67b3 server: bkctld-archive > Cleanup nspawn setup/config 2024-08-28 17:15:48 +02:00
75f9107ed0 server: Adapt bkctld-rename to the new nspawn setup 2024-08-28 17:15:48 +02:00
552d7e1c94 server: Move the nspawn config generation in a separate function 2024-08-28 17:15:48 +02:00
9bd104d430 server: bkctld-sync > Only sync /etc and /root from the jail 2024-08-28 17:15:48 +02:00
4de0e6ae7d server: bkctld-sync > Ensure that bkctld versions are identical and jail version too 2024-08-28 17:15:48 +02:00
7ceda42495 server: New command jail-version
Return the version of a given jail
2024-08-28 17:15:48 +02:00
1e4bf89082 server: Adapt command sync to the new folder structure 2024-08-28 17:15:48 +02:00
805f10ea83 server: Add missing call in bkctld for the convert-v2 command 2024-08-28 17:15:48 +02:00
20568f5a95 server: New command convert-v2
Convert a given jail to the new format
2024-08-28 17:15:48 +02:00
87c8372304 server: Validate the jail version before trying to change settings/update it 2024-08-28 17:15:48 +02:00
e0b5e76950 server: Extend the notion of Jail version
Add an internal function returning the jail version
2024-08-28 17:15:48 +02:00
e8ff20f140 server: Change start script to directly exec sshd
So we don't keep a sh process around.
Updated get_jail_sshd_pid accordingly with some comment
2024-08-28 17:15:48 +02:00
bde6e8da24 Show systemd property value directly 2024-08-28 17:15:48 +02:00
4fdba6cba4 Fix frenglish 2024-08-28 17:15:48 +02:00
b31834103a fix quotes
When strings must be quoted in messages, it's common to use an escaped backtick at the beginning, then a single-quote at the end.
2024-08-28 17:15:48 +02:00
c7ac0a78a6 typo 2024-08-28 17:15:48 +02:00
a7c542f3f3 server: new command log, to quickly show last logs from journalctl 2024-08-28 17:15:48 +02:00
8bfdf91941 server: Move from chroot to systemd-nspawn
Big change :
-> systemd-nspawn usage instead of chroot
-> Folder directory structure changes

Before : /backup/jails/JAIL_NAME/ <- RootFS of chroot jail
Now :
-  /backup/jails/JAIL_NAME/rootfs <- Jail rootfs (ro)
-  /backup/jails/JAIL_NAME/var <- Jail /var (rw)
-  /backup/jails/JAIL_NAME/data <- Jail /data (rw)

New dependencies :
- systemd-nspawn (package systemd-container on Debian)
- check_ssh (package monitoring-plugins-basic on Debian

Still a Work In Progress.
As of now, it won't work on existing servers as the jail folders needs
to be converted to the new folder structure
2024-08-28 17:15:48 +02:00
e13e2aa270 server: Remove deprecated sshd config options 2024-08-28 17:15:48 +02:00
Eric Morino
8b938fba25 Add options --host and --port for differents way to dump postgresql
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-08-28 15:40:32 +02:00
Eric Morino
d49335777b Add option option_dump_slave for dump_mysql_global 2024-08-28 15:13:05 +02:00
5557f42870
Client - Release 24.07
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
gitea/evobackup/pipeline/tag This commit looks good
2024-07-16 15:10:36 +02:00
93567b913f
dump/mysql.sh : give write permissions to mysql on tabs directories
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-07-16 15:08:12 +02:00
cb5bef3b54
Allow everybody to "x" on LOCAL_BACKUP_DIR
Set the directory permissions to 711 to allow anyone to walk through the backup directory, but not list the content
2024-07-16 15:08:12 +02:00
886e47ebf7
dump/postgresql: Fix dump_cmd usage
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
`var="(<cmd>)"; ${var}` doesn't work in shell.
Use "eval" to make it work.
2024-07-09 11:20:00 +02:00
ba087a2a35
dump/postgrepsql: Remove useless variables copied from dump/mysql
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
These caused errors, weren't used at all in the script outside of
changing the default value of another variable, and couldn't be set
anyway.

(We might want to re-add option_port later as it would be useful. But
right now it isn't usable at all.)
2024-07-09 10:56:47 +02:00
Alexis Ben Miloud--Josselin
e9d802105a dump/postgrepsql: Add missing variables
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
These variables were used but undefined. The lines come from
client/lib/dump/mysql.sh.
2024-07-08 10:16:49 +02:00
53ae37fcea
Use correct variable when detecting local sshrc template
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
2024-06-03 11:27:39 +02:00
201b22c145
Client - Release 24.05.1
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
gitea/evobackup/pipeline/tag This commit looks good
2024-05-14 08:19:37 +02:00
0e98c6d4cd
client: fix shell syntax error 2024-05-14 08:18:02 +02:00
f3cfda48f7
Client - Release 24.05
All checks were successful
gitea/evobackup/pipeline/head This commit looks good
gitea/evobackup/pipeline/tag This commit looks good
2024-05-02 10:22:39 +02:00
dc003ecbca
Add previous release dates in CHANGELOG 2024-05-02 10:20:53 +02:00
0d32cb2cde
evobackupctl: update LIBDIR when copying the template 2024-05-02 10:18:25 +02:00
96aa0cf7a2
mention the Ansible role in the client README 2024-05-02 10:17:46 +02:00
be6ebdf415
evobackupctl: simplify the program path retrieval 2024-05-02 10:17:22 +02:00
Alexis Ben Miloud--Josselin
9bfec89f18 Disable padding for the last column
Padding the last column on the right often produces messed up
output because lines are too long.
2021-12-06 10:29:55 +01:00
51 changed files with 1240 additions and 361 deletions

View file

@ -23,13 +23,69 @@ The **patch** part changes is incremented if multiple releases happen the same m
### Security
## [24.04.1]
## [25.01] - 2025-01-07
### Fixed
* dump_elasticsearch: Add an `\n` before HTTP status code
* Fix compatibility with OpenBSD
### Added
* Add function for backup Linstor Database
* Introducing munin-plugins for bkctld
## [24.12] - 2022-12-18
### Changed
* client: the template defaults to full Evolix backup
### Fixed
* client: add exclude for 'lxc/*/rootfs/dev'
## [24.11] - 2022-11-29
### Fixed
* dump_postgresql_per_base: look for correct variable to build connect options
* dump_postgresql_per_base: return if postgresql directory is missing
* dump_redis: choose all instances if none given
* dump_redis: clean backup directory only if the Redis instance is valid
* dump_redis: do not delete entire backup directory
* dump_redis: use dynamic config for each instance
## [24.07] - 2022-07-16
### Changed
* Allow everybody to "x" on LOCAL_BACKUP_DIR
* dump/mysql.sh : give write permissions to mysql on tabs directories
## [24.05.1] - 2022-05-14
### Fixed
* client: fix shell syntax error
## [24.05] - 2022-05-02
### Added
* evobackupctl: update LIBDIR when copying the template
### Changed
* evobackupctl: simplify the program path retrieval
## [24.04.1] - 2022-04-30
### Fixed
* evobackupctl: quote ARGS variable for options parsing.
## [24.04]
## [24.04] - 2022-04-29
### Added
@ -52,7 +108,7 @@ The **patch** part changes is incremented if multiple releases happen the same m
* don't exit the whole program if a sync task can't be done
## [22.12]
## [22.12] - 2022-12-27
### Changed
@ -77,6 +133,6 @@ The **patch** part changes is incremented if multiple releases happen the same m
* Make start_time and stop_time compatible with OpenBSD
## [22.03]
## [22.03] - 2022-04-03
Split client and server parts of the project

View file

@ -37,6 +37,8 @@ To install, copy these files :
To update, simply overwrite them, since their content should (must?) not be customized locally.
There is also an [evobackup-client](https://gitea.evolix.org/evolix/ansible-roles/src/branch/unstable/evobackup-client) Ansible role to do this (and some other stuff) automatically.
## Usage
### backup script

View file

@ -1,9 +1,8 @@
#!/usr/bin/env bash
# shellcheck disable=SC2155
readonly PROGNAME=$(basename "${0}")
# shellcheck disable=SC2155
readonly PROGDIR=$(readlink -m "$(dirname "${0}")")
readonly PROGPATH=$(readlink -f "${0}")
readonly PROGNAME=$(basename "${PROGPATH}")
# shellcheck disable=SC2124
readonly ARGS=$@
@ -36,6 +35,17 @@ Options
END
}
get_server_ip_from_external() {
curl --connect-timeout 10 --ipv4 https://ifconfig.me 2> /dev/null
}
get_server_ip_from_internal() {
if [ "$(uname -s)" = "OpenBSD" ]; then
ifconfig egress | grep "inet " | head -1 | awk '{ print $2}'
else
hostname -I | awk '{ print $1}'
fi
}
jail_init_commands() {
if [ ! -f /root/.ssh/id_ed25519.pub ]; then
ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ''
@ -44,11 +54,7 @@ jail_init_commands() {
SSH_KEY=$(cat /root/.ssh/id_ed25519.pub)
SERVER_NAME=$(hostname -s)
if [ "$(uname -s)" = "OpenBSD" ]; then
SERVER_IP=$(ifconfig egress | grep "inet " | head -1 | awk '{ print $2}')
else
SERVER_IP=$(curl -4 https://ifconfig.me 2> /dev/null || hostname -I | awk '{ print $1}')
fi
SERVER_IP=$(get_server_ip_from_external || get_server_ip_from_internal)
echo "Copy-paste those lines on backup server(s) :"
echo "----------"
@ -78,10 +84,15 @@ copy_template() {
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}"
# Insert metadata about the template
sed -i "s|@COMMAND@|${PROGPATH} ${ARGS}|" "${dest_path}"
# option "--iso-8601=seconds" does not exist on OpenBSD (and "%:z" neither)
sed -i "s|@DATE@|$(date +%FT%T%z)|" "${dest_path}"
sed -i "s|@VERSION@|${VERSION}|" "${dest_path}"
# Make sure that the library directory is correct
sed -i "s|^LIBDIR=.\+|LIBDIR=\"${LIBDIR}\"|" "${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

View file

@ -240,7 +240,7 @@ dump_elasticsearch() {
connect_options+=(${option_others})
fi
# Add the http return code at the end of the output
connect_options+=(--write-out '%{http_code}\n')
connect_options+=(--write-out '\n%{http_code}\n')
connect_options+=(--silent)
declare -a dump_options

View file

@ -34,12 +34,13 @@ dump_ldap() {
# Copy dump file of Redis instances
#
# Arguments:
# --instances=[Integer] (default: all)
# --instances=[String,String] (default: all)
#######################################################################
dump_redis() {
all_instances=$(find /var/lib/ -mindepth 1 -maxdepth 1 '(' -type d -o -type l ')' -name 'redis*')
all_instances=$( find /etc/redis*/redis.conf -print0 | xargs -0 -n 1 dirname | xargs -n 1 basename | sort -h | xargs )
declare -a option_instances
local option_instances=""
# Parse options, based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
while :; do
case ${1:-''} in
@ -87,51 +88,70 @@ dump_redis() {
shift
done
# If no instance has been give, use every instance found
if [ -z "${option_instances[*]}" ]; then
read -a option_instances <<< "${all_instances}"
fi
for instance in "${option_instances[@]}"; do
name=$(basename "${instance}")
local dump_dir="${LOCAL_BACKUP_DIR}/${name}"
local errors_dir=$(errors_dir_from_dump_dir "${dump_dir}")
rm -rf "${dump_dir}" "${errors_dir}"
mkdir -p "${dump_dir}" "${errors_dir}"
# No need to change recursively, the top directory is enough
chmod 700 "${dump_dir}" "${errors_dir}"
# Look for the config file for this instance
config_file="/etc/${instance}/redis.conf"
if [ -n "${instance}" ] && [ -f "${config_file}" ]; then
# Parse the config for he data dir and dump file
local instance_data_dir
local instance_data_file
local instance_dump_path
if [ -f "${instance}/dump.rdb" ]; then
local error_file="${errors_dir}/${name}.err"
log "LOCAL_TASKS - ${FUNCNAME[0]}: start ${dump_dir}"
instance_data_dir=$( grep --extended-regexp "^\s*dir " "${config_file}" | cut -d ' ' -f 2 | tr -d "'" | tr -d '"' )
instance_data_file=$( grep --extended-regexp "^\s*dbfilename " "${config_file}" | cut -d ' ' -f 2 | tr -d "'" | tr -d '"' )
instance_dump_path="${instance_data_dir}/${instance_data_file}"
# Copy the Redis database
dump_cmd="cp -a ${instance}/dump.rdb ${dump_dir}/dump.rdb"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${dump_cmd}"
${dump_cmd} 2> "${error_file}"
if [ -n "${instance_dump_path}" ]; then
local dump_dir="${LOCAL_BACKUP_DIR}/${instance}"
local errors_dir=$(errors_dir_from_dump_dir "${dump_dir}")
rm -rf "${dump_dir}" "${errors_dir}"
mkdir -p "${dump_dir}" "${errors_dir}"
# No need to change recursively, the top directory is enough
chmod 700 "${dump_dir}" "${errors_dir}"
local last_rc=$?
# shellcheck disable=SC2086
if [ ${last_rc} -ne 0 ]; then
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: cp ${instance}/dump.rdb to ${dump_dir} returned an error ${last_rc}" "${error_file}"
GLOBAL_RC=${E_DUMPFAILED}
local error_file="${errors_dir}/${instance}.err"
log "LOCAL_TASKS - ${FUNCNAME[0]}: start ${dump_dir}"
# Copy the Redis database
dump_cmd="cp -a ${instance_dump_path} ${dump_dir}/${instance_data_file}"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${dump_cmd}"
${dump_cmd} 2> "${error_file}"
local last_rc=$?
# shellcheck disable=SC2086
if [ ${last_rc} -ne 0 ]; then
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: cp ${instance_dump_path} to ${dump_dir} returned an error ${last_rc}" "${error_file}"
GLOBAL_RC=${E_DUMPFAILED}
else
rm -f "${error_file}"
fi
# Compress the Redis database
dump_cmd="gzip ${dump_dir}/${instance_data_file}"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${dump_cmd}"
${dump_cmd}
local last_rc=$?
# shellcheck disable=SC2086
if [ ${last_rc} -ne 0 ]; then
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: gzip ${dump_dir}/${instance_data_file} returned an error ${last_rc}" "${error_file}"
GLOBAL_RC=${E_DUMPFAILED}
else
rm -f "${error_file}"
fi
log "LOCAL_TASKS - ${FUNCNAME[0]}: stop ${dump_dir}"
else
rm -f "${error_file}"
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '${dump_file}' not found."
fi
# Compress the Redis database
dump_cmd="gzip ${dump_dir}/dump.rdb"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${dump_cmd}"
${dump_cmd}
local last_rc=$?
# shellcheck disable=SC2086
if [ ${last_rc} -ne 0 ]; then
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: gzip ${dump_dir}/dump.rdb returned an error ${last_rc}" "${error_file}"
GLOBAL_RC=${E_DUMPFAILED}
else
rm -f "${error_file}"
fi
log "LOCAL_TASKS - ${FUNCNAME[0]}: stop ${dump_dir}"
else
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '${instance}/dump.rdb' not found."
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '${config_file}' not found."
fi
done
}
@ -371,7 +391,7 @@ dump_raid_config() {
# --targets=[IP,HOST] (default: <none>)
#######################################################################
dump_traceroute() {
local option_targets=""
declare -a option_targets
# Parse options, based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
while :; do
@ -557,3 +577,70 @@ dump_facl() {
log "LOCAL_TASKS - ${FUNCNAME[0]}: stop ${dump_dir}"
}
#######################################################################
# Dump Linstor Database
#
# Arguments: <none>
#######################################################################
dump_linstordb() {
# Set dump and errors directories and files
local dump_dir="${LOCAL_BACKUP_DIR}/linstor"
local dump_file="${dump_dir}/dump_linstor_db"
local errors_dir=$(errors_dir_from_dump_dir "${dump_dir}")
local error_file="${errors_dir}/dump.err"
# Reset dump and errors directories
rm -rf "${dump_dir}" "${errors_dir}"
# shellcheck disable=SC2174
mkdir -p -m 700 "${dump_dir}" "${errors_dir}"
# Log the start of the function
log "LOCAL_TASKS - ${FUNCNAME[0]}: start ${dump_file}"
# Stop linstor-controller process before backup
linstorctrl_stop="/usr/bin/systemctl stop linstor-controller.service"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${linstorctrl_stop}"
# Execute stop linstor-controller
${linstorctrl_stop}
local last_rc=$?
if [ "${last_rc}" -ne "0" ]; then
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: linstor stopping service failed"
GLOBAL_RC=${E_DUMPFAILED}
else
# Prepare the dump command (errors go to the error file and the data to the dump file)
dump_cmd="/usr/share/linstor-server/bin/linstor-database export-db ${dump_file}"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${dump_cmd}"
# Execute the dump command
${dump_cmd} 2> ${error_file}
# Check result and deal with potential errors
local last_rc=$?
# shellcheck disable=SC2086
if [ ${last_rc} -ne 0 ]; then
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: linstor database export to ${dump_file} returned an error ${last_rc}" "${error_file}"
GLOBAL_RC=${E_DUMPFAILED}
else
rm -f "${error_file}"
fi
# Start linstor-controller process after backup
linstorctrl_start="/usr/bin/systemctl start linstor-controller.service"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${linstorctrl_start}"
# Execute start linstor-controller
${linstorctrl_start}
# Check result and deal with potential errors
local last_rc=$?
# shellcheck disable=SC2086
if [ ${last_rc} -ne 0 ]; then
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: linstor starting service failed"
GLOBAL_RC=${E_DUMPFAILED}
fi
fi
# Log the end of the function
log "LOCAL_TASKS - ${FUNCNAME[0]}: stop ${dump_file}"
}

View file

@ -504,6 +504,7 @@ dump_mysql_grants() {
# --dump-label=[String] (default: "default")
# used as suffix of the dump dir to differenciate multiple instances
# --compress=<gzip|pigz|bzip2|xz|none> (default: "gzip")
# --dump-slave=[1|2]
# Other options after -- are passed as-is to mysqldump
#######################################################################
dump_mysql_global() {
@ -518,6 +519,7 @@ dump_mysql_global() {
local option_dump_label=""
local option_compress=""
local option_others=""
local option_dump_slave=""
# Parse options, based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
while :; do
@ -696,6 +698,37 @@ dump_mysql_global() {
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--compress' requires a non-empty option argument."
exit 1
;;
--dump-slave)
# dump-slave options, require value "1" or "2"
if [ "$2" = "1" ]; then
option_dump_slave="--dump-slave=${2}"
shift
elif [ "$2" = "2" ]; then
option_dump_slave="--dump-slave=${2}"
shift
else
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--dump-slave' requires a non-empty option argument is \"1\" or \"2\"."
exit 1
fi
;;
--dump-slave=?*)
value="${1#*=}"
if [ ${value} = "1" ]; then
option_dump_slave="${1}"
shift
elif [ ${value} = "2" ]; then
option_dump_slave="${1}"
shift
else
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--dump-slave' require value \"1\" or \"2\"."
exit 1
fi
;;
--dump-slave=)
# dump-slave options, without value
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--dump-slave' requires a non-empty option argument, value is \"1\" or \"2\"."
exit 1
;;
--)
# End of all options.
shift
@ -800,6 +833,9 @@ dump_mysql_global() {
if [ -n "${option_masterdata}" ]; then
dump_options+=("${option_masterdata}")
fi
if [ -n "${option_dump_slave}" ]; then
dump_options+=("${option_dump_slave}")
fi
if [ -n "${option_others}" ]; then
# word splitting is deliberate here
# shellcheck disable=SC2206
@ -1510,8 +1546,8 @@ dump_mysql_tabs() {
rm -rf "${dump_dir}" "${errors_dir}"
mkdir -p "${dump_dir}" "${errors_dir}"
# No need to change recursively, the top directory is enough
chmod 700 "${dump_dir}" "${errors_dir}"
chown -RL mysql "${dump_dir}"
chmod 750 "$(dirname "${dump_dir}")" "${errors_dir}"
chown -RL mysql:mysql "$(dirname "${dump_dir}")"
local error_file="${errors_dir}.err"
log "LOCAL_TASKS - ${FUNCNAME[0]}: start ${dump_dir}"

View file

@ -8,12 +8,15 @@
# --dump-label=[String] (default: "default")
# used as suffix of the dump dir to differenciate multiple instances
# --compress=<gzip|pigz|bzip2|xz|none> (default: "gzip")
# --host=<ip|socket_dir> (default: "/var/lib/postgresql")
# Other options after -- are passed as-is to pg_dump
#######################################################################
dump_postgresql_global() {
local option_dump_label=""
local option_compress=""
local option_others=""
local option_host=""
local option_port=""
# Parse options, based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
while :; do
@ -56,6 +59,44 @@ dump_postgresql_global() {
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--compress' requires a non-empty option argument."
exit 1
;;
--host)
# host options, with value separated by space
if [ -n "$2" ]; then
option_host="${2}"
shift
else
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--host' requires a non-empty option argument."
exit 1
fi
;;
--host=?*)
# host options, with value separated by =
option_host="${1#*=}"
;;
--host=)
# host options, without value
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--host' requires a non-empty option argument."
exit 1
;;
--port)
# port options, with value separated by space
if [ -n "$2" ]; then
option_port="${2}"
shift
else
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--port' requires a non-empty option argument."
exit 1
fi
;;
--port=?*)
# port options, with value separated by =
option_port="${1#*=}"
;;
--port=)
# port options, without value
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--port' requires a non-empty option argument."
exit 1
;;
--)
# End of all options.
shift
@ -99,15 +140,7 @@ dump_postgresql_global() {
esac
if [ -z "${option_dump_label}" ]; then
if [ -n "${option_defaults_group_suffix}" ]; then
option_dump_label="${option_defaults_group_suffix}"
elif [ -n "${option_port}" ]; then
option_dump_label="${option_port}"
elif [ -n "${option_socket}" ]; then
option_dump_label=$(path_to_str "${option_socket}")
else
option_dump_label="default"
fi
option_dump_label="default"
fi
local dump_dir="${LOCAL_BACKUP_DIR}/postgresql-${option_dump_label}-global"
@ -124,6 +157,15 @@ dump_postgresql_global() {
declare -a dump_options
dump_options=()
if [ -n "${option_host}" ]; then
dump_options+=(--host ${option_host})
if [ -n "${option_port}" ]; then
dump_options+=(--port ${option_port})
else
dump_options+=(--port 5432)
fi
fi
if [ -n "${option_others}" ]; then
# word splitting is deliberate here
# shellcheck disable=SC2206
@ -132,7 +174,7 @@ dump_postgresql_global() {
dump_cmd="(sudo -u postgres pg_dumpall ${dump_options[*]}) 2> ${error_file} | ${compress_cmd} > ${dump_file}"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${dump_cmd}"
${dump_cmd}
eval "${dump_cmd}"
local last_rc=$?
# shellcheck disable=SC2086
@ -166,6 +208,8 @@ dump_postgresql_per_base() {
local option_dump_label=""
local option_compress=""
local option_others=""
local option_host=""
local option_port=""
# Parse options, based on https://gist.github.com/deshion/10d3cb5f88a21671e17a
while :; do
@ -208,6 +252,44 @@ dump_postgresql_per_base() {
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--compress' requires a non-empty option argument."
exit 1
;;
--host)
# host options, with value separated by space
if [ -n "$2" ]; then
option_host="${2}"
shift
else
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--host' requires a non-empty option argument."
exit 1
fi
;;
--host=?*)
# host options, with value separated by =
option_host="${1#*=}"
;;
--host=)
# host options, without value
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--host' requires a non-empty option argument."
exit 1
;;
--port)
# port options, with value separated by space
if [ -n "$2" ]; then
option_port="${2}"
shift
else
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--port' requires a non-empty option argument."
exit 1
fi
;;
--port=?*)
# port options, with value separated by =
option_port="${1#*=}"
;;
--port=)
# port options, without value
log_error "LOCAL_TASKS - ${FUNCNAME[0]}: '--port' requires a non-empty option argument."
exit 1
;;
--)
# End of all options.
shift
@ -251,15 +333,7 @@ dump_postgresql_per_base() {
esac
if [ -z "${option_dump_label}" ]; then
if [ -n "${option_defaults_group_suffix}" ]; then
option_dump_label="${option_defaults_group_suffix}"
elif [ -n "${option_port}" ]; then
option_dump_label="${option_port}"
elif [ -n "${option_socket}" ]; then
option_dump_label=$(path_to_str "${option_socket}")
else
option_dump_label="default"
fi
option_dump_label="default"
fi
local dump_dir="${LOCAL_BACKUP_DIR}/postgresql-${option_dump_label}-per-base"
@ -271,8 +345,21 @@ dump_postgresql_per_base() {
(
# shellcheck disable=SC2164
cd /var/lib/postgresql
databases=$(sudo -u postgres psql -U postgres -lt | awk -F \| '{print $1}' | grep -v "template.*")
declare -a connect_options
if [ -n "${option_host}" ]; then
connect_options+=(--host ${option_host})
if [ -n "${option_port}" ]; then
connect_options+=(--port ${option_port})
else
connect_options+=(--port 5432)
fi
fi
cd /var/lib/postgresql || { log "LOCAL_TASKS - ${FUNCNAME[0]}: /var/lib/postgresql not found"; return; }
databases=$(sudo -u postgres psql -U postgres ${connect_options[*]} -lt | awk -F \| '{print $1}' | grep -v "template.*")
for database in ${databases} ; do
local error_file="${errors_dir}/${database}.err"
local dump_file="${dump_dir}/${database}.sql${dump_ext}"
@ -283,6 +370,16 @@ dump_postgresql_per_base() {
dump_options+=(--create)
dump_options+=(-U postgres)
dump_options+=(-d "${database}")
if [ -n "${option_host}" ]; then
dump_options+=(--host ${option_host})
if [ -n "${option_port}" ]; then
dump_options+=(--port ${option_port})
else
dump_options+=(--port 5432)
fi
fi
if [ -n "${option_others}" ]; then
# word splitting is deliberate here
# shellcheck disable=SC2206
@ -291,7 +388,7 @@ dump_postgresql_per_base() {
dump_cmd="(sudo -u postgres /usr/bin/pg_dump ${dump_options[*]}) 2> ${error_file} | ${compress_cmd} > ${dump_file}"
log "LOCAL_TASKS - ${FUNCNAME[0]}: ${dump_cmd}"
${dump_cmd}
eval "${dump_cmd}"
local last_rc=$?
# shellcheck disable=SC2086

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034,SC2317
readonly VERSION="24.04.1"
readonly VERSION="25.01"
# set all programs to C language (english)
export LC_ALL=C
@ -133,6 +133,7 @@ sync_tasks_wrapper() {
'lxc/*/rootfs/var/run'
'lxc/*/rootfs/var/state'
'lxc/*/rootfs/var/tmp'
'lxc/*/rootfs/dev'
/home/mysqltmp
)
readonly rsync_default_excludes
@ -378,7 +379,7 @@ setup() {
: "${LOCAL_BACKUP_DIR:="/home/backup"}"
# shellcheck disable=SC2174
mkdir -p -m 700 "${LOCAL_BACKUP_DIR}"
mkdir -p -m 711 "${LOCAL_BACKUP_DIR}"
: "${ERRORS_DIR:="${LOCAL_BACKUP_DIR}/${PROGNAME}.errors-${START_TIME}"}"
# shellcheck disable=SC2174

View file

@ -105,7 +105,7 @@ test_server() {
pick_server() {
local -i increment=${1:-0}
local -i list_length=${#SERVERS[@]}
local sync_name=${2:""}
local sync_name=${2:-""}
if (( increment >= list_length )); then
# We've reached the end of the list

View file

@ -45,9 +45,9 @@ MAIL=__NOTIFICATION_MAIL__
# shellcheck disable=SC2034
sync_tasks() {
########## System-only backup (to Evolix servers) #################
########## Backup to Evolix servers ###############################
SYNC_NAME="evolix-system"
SYNC_NAME="evolix"
SERVERS=(
__SRV0_HOST__:__SRV0_PORT__
__SRV1_HOST__:__SRV1_PORT__
@ -57,6 +57,8 @@ sync_tasks() {
/etc
/root
/var
/home
/srv
)
RSYNC_EXCLUDES=(
"${rsync_default_excludes[@]}"
@ -64,9 +66,9 @@ sync_tasks() {
sync "${SYNC_NAME}" "SERVERS[@]" "RSYNC_INCLUDES[@]" "RSYNC_EXCLUDES[@]"
########## Full backup (to client servers) ########################
########## Backup to client servers ###############################
### SYNC_NAME="client-full"
### SYNC_NAME="client"
### SERVERS=(
### client-backup00.evolix.net:2221
### client-backup01.evolix.net:2221
@ -219,7 +221,9 @@ local_tasks() {
# Copy data file for all instances
#
### dump_redis [--instances=<all|instance1|instance2>]
# The instance name is the config directory name
# eg. "redis" for "/etc/redis/", "redis-foo" for "/etc/redis-foo"
### dump_redis [--instances=<all|instance1,instance2>]
########## Elasticsearch ##########

View file

@ -13,18 +13,100 @@ The **patch** part changes is incremented if multiple releases happen the same m
### Added
* bkctld-check-setup: Check how many incs operation are running (Critical if >=2)
* bkctld-check-setup: Check if inc and rm operations are running simultaneously (Warning if yes)
* bkctld-check-setup: Check if inc creation time (in the last 10 days) is bellow given thresholds
* bkctld-check-setup: Check if there is more than 1 unfinished inc operation
* bkctld-inc: Save inc creation time
* Directory /var/lib/bkctld to store internal bkctld informations
* Munin plugins for bkctld [#64](https://gitea.evolix.org/evolix/evobackup/pulls/64)
### Changed
* bkctld-inc: Add log message at begining/end of operations (with the inc name)
* bkctld-inc: Inverted log message priorities (progre