-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapache-bkp.sh
More file actions
executable file
·75 lines (67 loc) · 3.97 KB
/
apache-bkp.sh
File metadata and controls
executable file
·75 lines (67 loc) · 3.97 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# apache-bkp.sh - Respaldo del sistema de gestion de contenidos WordPress
#
# Copyright © 2019, Rodrigo Ernesto Alvarez Aguilera <incognia@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Version 0.1 - September 15, 2019
# Author: Rodrigo Ernesto Alvarez Aguilera
#
# Tested under Debian GNU/Linux 9.7 using GNU bash version 4.4.12
#
HELP="Uso: apache-bkp.sh [OPCIÓN]\n\n
\t-h\tmuestra esta lista de ayuda\n
\t-l\tmuestra la licencia del programa\n
\t-v\tmuestra la versión del programa\n"
VERSION="apache-bkp.sh versión 0.1\n
\bCopyright © 2019, Rodrigo Ernesto Alvarez Aguilera"
DATE=`date +%Y%m%d`
HOST=`hostname`
DATABASE=[database name]
DBUSER=[database user]
DBPASS=[dabase password]
if [[ $1 = "-h" ]]; then
echo -e $HELP
elif [[ $1 = "-l" ]]; then
more LICENSE
elif [[ $1 = "-v" ]]; then
echo -e $VERSION
else
# Respaldar y comprimir directorio "html"
tar -czvf $DATE-$HOST-html.tar.gz /var/www/html/
# Respaldar base de datos
mysqldump -u $DBUSER -p$DBPASS $DATABASE > $DATABASE.sql
# Comprimir respaldo de base de datos
tar -czvf $DATE-$HOST-$DATABASE.tar.gz $DATABASE.sql
# Eliminar respaldo de base de datos
rm $DATABASE.sql
echo -e "┌──────────────────────────────────────────────────────────────────────────────┐"
echo -e "│ Generando informe... │"
echo -e "└──────────────────────────────────────────────────────────────────────────────┘"
# Generar suma MD5
md5sum $DATE-*.gz > md5.tmp
reset
# Listar archivos
echo -e "┌──────────────────────────────────────────────────────────────────────────────┐"
echo -e "│ Respaldo de directorios y base de datos de finalizado │"
echo -e "└──────────────────────────────────────────────────────────────────────────────┘"
ls -hl $DATE-*.gz
echo -e " ────────────────────────────────────────────────────────────────────────────── "
cat md5.tmp
echo -e "┌──────────────────────────────────────────────────────────────────────────────┐"
echo -e "│ Copyright © 2019, Rodrigo Ernesto Alvarez Aguilera │"
echo -e "└──────────────────────────────────────────────────────────────────────────────┘"
rm md5.tmp
fi