-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwp-bkp.sh
More file actions
executable file
·87 lines (78 loc) · 4.5 KB
/
wp-bkp.sh
File metadata and controls
executable file
·87 lines (78 loc) · 4.5 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
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# wp-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.2 - May 13, 2019
# Author: Rodrigo Ernesto Alvarez Aguilera
#
# Tested under Debian GNU/Linux 9.7 using GNU bash version 4.4.12
#
HELP="Uso: wp-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="wp-bkp.sh versión 0.2\n
\bCopyright © 2019, Rodrigo Ernesto Alvarez Aguilera"
DATABASE="wordpress"
DBUSER=[database user]
DBPASS=[dabase password]
DATE=`date +%Y%m%d`
HOST=`hostname`
NFS=[nfs server]
if [[ $1 = "-h" ]]; then
echo -e $HELP
elif [[ $1 = "-l" ]]; then
more LICENSE
elif [[ $1 = "-v" ]]; then
echo -e $VERSION
else
# Matar procesos usando directorio NFS
fuser -k -9 /var/www/html/archivos/
# Desmontar directorio NFS
umount /var/www/html/archivos/
df -h
sleep 5
# 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-wordpress.tar.gz wordpress.sql
# Eliminar respaldo de base de datos
rm wordpress.sql
# Montar directorio NFS
mount -t nfs $NFS:/data/archivos /var/www/html/archivos/
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 WordPress finalizado │"
echo -e "└──────────────────────────────────────────────────────────────────────────────┘"
df -h |grep -e File -e archivos
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