toinst: implémenter la sauvegarde
This commit is contained in:
parent
fc467cb250
commit
2394edf7da
58
toinst
58
toinst
|
@ -494,11 +494,59 @@ fi
|
|||
|
||||
## Sauvegarde
|
||||
if [ -n "$BACKUP" -o "$action" == backup ]; then
|
||||
if [ -n "$fake" ]; then
|
||||
:
|
||||
[ -n "$CATALINA_BASE" -o -z "$will_deploy" ] || die "Vous devez spécifier l'option --catalina-base"
|
||||
|
||||
home_bckdir="$HOME/tomcat-backups"
|
||||
if [ -n "$istmpdir" ]; then
|
||||
# déploiement distant: sauvegarder dans le répertoire utilisateur
|
||||
default_bckdir="$home_bckdir"
|
||||
else
|
||||
:
|
||||
# déploiement local: ça dépend de la webapp
|
||||
default_bckdir=
|
||||
fi
|
||||
setx cwd=pwd
|
||||
|
||||
etitle "Sauvegarde des webapps"
|
||||
for deploymap in "${deploymaps[@]}"; do
|
||||
splitpair "$deploymap" waname src
|
||||
wadir="$CATALINA_BASE/webapps/$waname"
|
||||
|
||||
if [ ! -d "$wadir" ]; then
|
||||
einfo "$waname: la webapp n'a pas encore été déployée. elle ne sera pas sauvegardée"
|
||||
continue
|
||||
fi
|
||||
|
||||
bckdir="$default_bckdir"
|
||||
if [ -z "$bckdir" ]; then
|
||||
if withinpath "$tmpdir" "$src"; then
|
||||
bckdir="$home_bckdir"
|
||||
elif withinpath "$src" "$cwd"; then
|
||||
setx bckdir=dirname "$src"
|
||||
else
|
||||
bckdir=.
|
||||
fi
|
||||
fi
|
||||
mkdir -p "$bckdir"
|
||||
|
||||
setx base=date +%y%m%d
|
||||
i=0
|
||||
bckname="$base.$profile$i-$waname"
|
||||
while [ -d "$bckdir/$bckname" ]; do
|
||||
let i=$i+1
|
||||
bckname="$base.$profile$i-$waname"
|
||||
done
|
||||
|
||||
if [ -n "$fake" ]; then
|
||||
evalx qvals rsync -a "$wadir/" "$bckdir/$bckname" // eecho
|
||||
else
|
||||
estep "$wadir --> $(ppath "$bckdir/$bckname")"
|
||||
if ! rsync -a "$wadir/" "$bckdir/$bckname"; then
|
||||
ewarn "Une erreur s'est produite pendant la sauvegarde"
|
||||
ask_yesno "Voulez-vous continuer le déploiement?" N || die
|
||||
fi
|
||||
fi
|
||||
done
|
||||
eend
|
||||
fi
|
||||
|
||||
## Déploiement
|
||||
|
@ -507,7 +555,7 @@ if [ "$action" == deploy ]; then
|
|||
|
||||
if [ -n "$fake" ]; then
|
||||
# Afficher ce qu'il faut faire
|
||||
etitle "Variables définies" __dump_vars
|
||||
etitle "Configuration globale" __dump_vars
|
||||
etitle "Déploiements des webapps"
|
||||
for deploymap in "${deploymaps[@]}"; do
|
||||
splitpair "$deploymap" waname src
|
||||
|
@ -515,7 +563,7 @@ if [ "$action" == deploy ]; then
|
|||
dest="${CATALINA_BASE:-CATALINA_BASE}/webapps/$waname"
|
||||
etitle "$waname"
|
||||
if [ -f "$src/.toinst.conf" ]; then
|
||||
etitle "Variables locales"
|
||||
etitle "Configuration de la webapp"
|
||||
(
|
||||
EXCLUDES=()
|
||||
PROTECTS=()
|
||||
|
|
Loading…
Reference in New Issue