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