]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - modules/role/templates/backup/backup_dirname_head.sh.erb
Add a way to specify a port for backup hosts
[perso/Immae/Projets/Puppet.git] / modules / role / templates / backup / backup_dirname_head.sh.erb
1 ##### <%= @dirname %> #####
2 PORT="<%= @port %>"
3 DEST="<%= @dest %>"
4 BASE="<%= @base %>"
5 OLD_BAK_BASE=$BASE/older/j
6 BAK_BASE=${OLD_BAK_BASE}0
7 RSYNC_OUTPUT=$BASE/rsync_output
8 NBR=<%= @nbr %>
9
10 if ! ssh \
11 -o PreferredAuthentications=publickey \
12 -o StrictHostKeyChecking=yes \
13 -o ClearAllForwardings=yes \
14 -p $PORT \
15 $DEST backup; then
16 echo "Fichier de verrouillage backup sur $DEST ou impossible de se connecter" >&2
17 skip=$DEST
18 fi
19
20 rm -rf ${OLD_BAK_BASE}${NBR}
21 for j in `seq -w $(($NBR-1)) -1 0`; do
22 [ ! -d ${OLD_BAK_BASE}$j ] && continue
23 mv ${OLD_BAK_BASE}$j ${OLD_BAK_BASE}$(($j+1))
24 done
25 mkdir $BAK_BASE
26 mv $RSYNC_OUTPUT $BAK_BASE
27 mkdir $RSYNC_OUTPUT
28
29 if [ "$skip" != "$DEST" ]; then