summaryrefslogtreecommitdiff
path: root/bin/sync/sync-wiki.sh
blob: 0abf5a8af9eed66f3c91a42b33e9febc4b680bd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# ----
# Copyright (C) 2013-2020 - Reevo Project (http://reevo.org)
# License: Affero GPL version 3 - http://www.gnu.org/licenses/agpl.html
# ES: Este archivos es parte de: reevo-web (http://git.reevo.org/reevo/reevo-web)
# EN: This file is part of: reevo-web (http://git.reevo.org/reevo/reevo-web)
# ----

REMOTO="reevo.red"

RUTA=`cat ../../etc/global_config.php | grep '^$REEVO_PATH' | cut -d '"' -f 2`
DOMINIO=`cat $RUTA/etc/global_config.php | grep '^$REEVO_URL' | cut -d '"' -f 2`
USER=`cat $RUTA/etc/global_config.php | grep '^$REEVO_DB_USER' | cut -d '"' -f 2`
PASSWORD=`cat $RUTA/etc/global_config.php | grep '^$REEVO_DB_PASS' | cut -d '"' -f 2`

DB=`cat $RUTA/etc/global_config.php | grep '^$REEVO_DB_WIKI' | cut -d '"' -f 2`
TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S`


echo "Vamos a sincronizar la BD y archivos desde $REMOTO hasta aqui $DOMINIO. Presione ENTER para continuar o cancele..."
read

echo ""
echo "###################"
echo "Hacemos un backup de la base de datos que tenemos en este servidor"
../bkp/bkp_wiki.sh

echo ""
echo "###################"
echo "Generamos una copia de la BD en el servidor remoto"
ssh $REMOTO "$RUTA/bin/bkp/bkp_wiki.sh"

echo ""
echo "Copiamos la BD desde el servidor hasta aqui"
scp "$REMOTO:$RUTA/bkp/wiki/ultimo" "/tmp/$REMOTO-$DB.sql.bz2"

echo ""
echo "Descomprimimos e importamos"
bunzip2 "/tmp/$REMOTO-$DB.sql.bz2"
# mysql --user=$USER --password=$PASSWORD -e "CREATE database if not exists $BDIMPORT;"
# mysql --user=$USER --password=$PASSWORD $DB <  "/tmp/$REMOTO-$DB.sql"

echo ""
echo "Borramos los temporales"
# rm "/tmp/$REMOTO-$DB.sql"

# echo ""
# echo "ETAPA 2: Vamos a sincronizar algunos directorios con archivos..."
# sleep 2s
# rsync -P -r -a -v -e "ssh -l reevo" --delete beta.reevo.org:/srv/reevo.org/var/elgg/ /srv/dev/files/red/