From f14795b63309d71ab649c3cedad67b249b19e763 Mon Sep 17 00:00:00 2001 From: Yaco Date: Thu, 29 Aug 2019 18:24:30 -0300 Subject: agrega sistema de backups integrado --- .gitignore | 3 +++ bin/bkp/bkp_wiki.sh | 27 +++++++++++++++++++++++++ bin/sync/database_auth.sh | 9 +++++++++ bin/sync/sync-wiki.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++++ bkp/wiki/.gitkeep | 0 5 files changed, 89 insertions(+) create mode 100755 bin/bkp/bkp_wiki.sh create mode 100755 bin/sync/database_auth.sh create mode 100755 bin/sync/sync-wiki.sh create mode 100644 bkp/wiki/.gitkeep diff --git a/.gitignore b/.gitignore index cfb57725..58bd1b72 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ *.log export-*.json +bkp/wiki/* +!bkp/wiki/.gitkeep + log/admin/* log/crm/* log/wiki/* diff --git a/bin/bkp/bkp_wiki.sh b/bin/bkp/bkp_wiki.sh new file mode 100755 index 00000000..369b1ce2 --- /dev/null +++ b/bin/bkp/bkp_wiki.sh @@ -0,0 +1,27 @@ +#!/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) +# ---- + +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 "" +echo "Se va a generar una copia de la BD: $DB" +mysqldump --user=$USER --password=$PASSWORD $DB > "$RUTA/bkp/wiki/$DOMINIO-$DB-$TIMESTAMP.sql" + +echo "" +echo "Se comprime la BD" +bzip2 "$RUTA/bkp/wiki/$DOMINIO-$DB-$TIMESTAMP.sql" + +echo "Generamos enlace simbolico" +rm "$RUTA/bkp/wiki/ultimo" +ln -s "$RUTA/bkp/wiki/$DOMINIO-$DB-$TIMESTAMP.sql.bz2" "$RUTA/bkp/wiki/ultimo" diff --git a/bin/sync/database_auth.sh b/bin/sync/database_auth.sh new file mode 100755 index 00000000..3317b4a1 --- /dev/null +++ b/bin/sync/database_auth.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# ES: Reemplaza con las credenciales de acceso a Mysql y renombra este archivo como "database_auth.sh" +# EN: Replace with Mysql DB access information and rename this file as "database_auth.sh" + +USER="reevo_web" +PASS="yaco22" +DOMAIN="reevo.wiki" +VERSION="ALFA" diff --git a/bin/sync/sync-wiki.sh b/bin/sync/sync-wiki.sh new file mode 100755 index 00000000..0abf5a8a --- /dev/null +++ b/bin/sync/sync-wiki.sh @@ -0,0 +1,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/ diff --git a/bkp/wiki/.gitkeep b/bkp/wiki/.gitkeep new file mode 100644 index 00000000..e69de29b -- cgit v1.2.1