-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmtkback
100 lines (85 loc) · 2.27 KB
/
mtkback
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
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
# Made by Sinfallas <sinfallas@yahoo.com>
# Licence: GPL-2
LC_ALL=C
SECONDS=0
LOCKFILE="/tmp/$(basename $0)_$(whoami)"
archi="/app/log.txt"
source /usr/bin/mtkvariables
function clean_1() {
rm -f /tmp/$(basename $0)_$(whoami)
rm -f /run/$(basename $0).pid
}
echo "$BASHPID" > /run/$(basename $0).pid
trap "clean_1; exit" 0 1 2 3 9 15
lock || exit_error
if [[ -z "$suser" ]]; then
ayuda
fi
if [[ -z "$sshport" ]]; then
ayuda
fi
if [[ -z "$sshpass" ]]; then
ayuda
fi
if [[ -z "$ips" ]]; then
ayuda
fi
if [[ -z "$cport" ]]; then
ayuda
fi
if [[ -z "$cuser" ]]; then
ayuda
fi
if [[ -z "$cpass" ]]; then
ayuda
fi
if [[ -z "$cdestinos" ]]; then
ayuda
fi
if [[ -z "$cfrom" ]]; then
ayuda
fi
clear
for i in ${ips[@]}; do
echo "IP: $i"
echo "IP: $i" >> "$archi"
echo "=========================" >> "$archi"
if [[ "$sshport" == "22" ]]; then
echo "Creando Backup"
echo "Creando Backup" >> "$archi"
sshpass -p $sshpass $cssh $suser@$i "$back name="$i""
echo "Creando Terse"
echo "Creando Terse" >> "$archi"
sshpass -p $sshpass $cssh $suser@$i "$terse file="$i""
echo "Descargando Backup"
echo "Descargando Backup" >> "$archi"
sshpass -p $sshpass $cscp $suser@$i:$i.backup "$donde"/
echo "Descargando Terse"
echo "Descargando Terse" >> "$archi"
sshpass -p $sshpass $cscp $suser@$i:$i.rsc "$donde"/
else
echo "Creando Backup"
echo "Creando Backup" >> "$archi"
sshpass -p $sshpass $cssh -p $sshport $suser@$i "$back name="$i""
echo "Creando Terse"
echo "Creando Terse" >> "$archi"
sshpass -p $sshpass $cssh -p $sshport $suser@$i "$terse file="$i""
echo "Descargando Backup"
echo "Descargando Backup" >> "$archi"
sshpass -p $sshpass $cscp -P $sshport $suser@$i:$i.backup "$donde"/
echo "Descargando Terse"
echo "Descargando Terse" >> "$archi"
sshpass -p $sshpass $cscp -P $sshport $suser@$i:$i.rsc "$donde"/
fi
done
echo "Comprimiendo"
$ctar "$donde"/backup-"$fecha".tar.gz "$donde"/
if [[ -z "$cserver" ]]; then
echo "No se enviara correo."
else
$cmdcorreo --header "Subject: Respaldo de configuracion de los Mikrotik en %DATE%" --body "Se adjunta el archivo." --attach-type "application/x-compressed-tar" --attach-name "backup-$fecha.tar.gz" --attach @/app/backup-$fecha.tar.gz
fi
echo "duracion $SECONDS segundos"
echo "Finalizado."
exit 0