Switch to bash and properly rotate servers
Arithmetics should be used to should a server from a list but not to compose the name of the server. Also, server names are not always composed of a numeric part that could be determined automatically.
This commit is contained in:
parent
f7b8e96547
commit
3b396b8f2d
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Script Evobackup client
|
# Script Evobackup client
|
||||||
# See https://forge.evolix.org/projects/evobackup
|
# See https://forge.evolix.org/projects/evobackup
|
||||||
#
|
#
|
||||||
# Author: Gregory Colpart <reg@evolix.fr>
|
# Author: Gregory Colpart <reg@evolix.fr>
|
||||||
# Contributor: Romain Dessort <rdessort@evolix.fr>, Benoît Série <bserie@evolix.fr>, Tristan Pilat <tpilat@evolix.fr>, Victor Laborie <vlaborie@evolix.fr>, Jérémy Lecour <jlecour@evolix.fr>
|
# Contributor: Romain Dessort <rdessort@evolix.fr>, Benoît Série <bserie@evolix.fr>, Tristan Pilat <tpilat@evolix.fr>, Victor Laborie <vlaborie@evolix.fr>, Jérémy Lecour <jlecour@evolix.fr>
|
||||||
# Licence: AGPLv3
|
# Licence: AGPLv3
|
||||||
|
@ -39,11 +39,15 @@ MAIL=jdoe@example.com
|
||||||
# choose "linux" or "bsd"
|
# choose "linux" or "bsd"
|
||||||
SYSTEM=$(uname | tr '[:upper:]' '[:lower:]')
|
SYSTEM=$(uname | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
# Variable to choose different backup server with date
|
# list of backup servers to use
|
||||||
NODE=$(($(date +%e) % 2))
|
NODES=(
|
||||||
|
"node0.backup.example.com"
|
||||||
# serveur address for rsync
|
"node1.backup.example.com"
|
||||||
SRV="node$NODE.backup.example.com"
|
)
|
||||||
|
NB_NODES=${#NODES[@]}
|
||||||
|
# select a server depending on the current date
|
||||||
|
I=$((10#$(date +%d) % ${NB_NODES}))
|
||||||
|
SRV=${NODES[$I]}
|
||||||
|
|
||||||
## We use /home/backup : feel free to use your own dir
|
## We use /home/backup : feel free to use your own dir
|
||||||
mkdir -p -m 700 /home/backup
|
mkdir -p -m 700 /home/backup
|
||||||
|
|
Loading…
Reference in a new issue