|
@@ -20,22 +20,23 @@
|
|
|
|
|
|
#Check things (root, 7z, mysql, ...)
|
|
|
startTime=$(date +"%s")
|
|
|
-if [ $(whoami) != "root" ]; then
|
|
|
+if [ $(id -u) -ne 0 ]; then
|
|
|
printf "ERROR:\tTienes que ser root :O\n"
|
|
|
exit 1
|
|
|
fi
|
|
|
-if [ ! -x /usr/bin/7z ]; then
|
|
|
+if [ ! -x "$(which 7z)" ]; then
|
|
|
printf "ERROR:\t7z Not Installed :O\n"
|
|
|
exit 1
|
|
|
fi
|
|
|
-if [ ! -x /usr/bin/mysql ]; then
|
|
|
+if [ ! -x "$(which mysql)" ]; then
|
|
|
printf "ERROR:\tMySQL Not Installed :O\n"
|
|
|
exit 1
|
|
|
fi
|
|
|
-if [ ! -x /usr/bin/mysqldump ]; then
|
|
|
+if [ ! -x "$(which mysqldump)" ]; then
|
|
|
printf "ERROR:\tMySQL Not Installed :O\n"
|
|
|
exit 1
|
|
|
fi
|
|
|
+exit 0
|
|
|
|
|
|
#Data
|
|
|
mysqluser="root"
|
|
@@ -66,7 +67,7 @@ lista=$(mysql -u $mysqluser -p$mysqlpass -e "show DATABASES;")
|
|
|
#Parse databases expect information_schema, mysql & performance_schema
|
|
|
for database in $lista; do
|
|
|
valid=true
|
|
|
- for excep in Database information_schema mysql performance_schema; do
|
|
|
+ for excep in Database information_schema performance_schema; do
|
|
|
if [ $database = $excep ]; then
|
|
|
valid=false
|
|
|
break
|
|
@@ -89,8 +90,8 @@ if [ $? != 0 ];then
|
|
|
fi
|
|
|
|
|
|
#Copy Email (this could be heavy in the future)
|
|
|
-printf "Comprimiendo:\t%s\n" /var/mail
|
|
|
-7z a -t7z -mx=9 -p$pass7z -mhe $backupOutput /var/mail > /dev/null
|
|
|
+printf "Comprimiendo:\t%s\n" /var/spool/mail
|
|
|
+7z a -t7z -mx=9 -p$pass7z -mhe $backupOutput /var/spool/mail > /dev/null
|
|
|
if [ $? != 0 ];then
|
|
|
printf "WARNING:\tError copiando emails (Ejecucion continua).\n"
|
|
|
fi
|
|
@@ -103,15 +104,22 @@ if [ $? != 0 ];then
|
|
|
fi
|
|
|
|
|
|
#Copy /home
|
|
|
-printf "Comprimiendo:\t%s\n" /home/
|
|
|
+printf "Comprimiendo:\t%s\n" /home
|
|
|
7z a -t7z -mx=9 -p$pass7z -mhe $backupOutput /home > /dev/null
|
|
|
if [ $? != 0 ];then
|
|
|
printf "WARNING:\tError copiando carpeta personal (Ejecucion continua).\n"
|
|
|
fi
|
|
|
|
|
|
+#Copy GOGS
|
|
|
+printf "Comprimiendo:\t%s\n" /opt/gogs
|
|
|
+7z a -t7z -mx=9 -p$pass7z -mhe $backupOutput /opt/gogs > /dev/null
|
|
|
+if [ $? != 0 ];then
|
|
|
+ printf "WARNING:\tError copiando GOGS (Ejecucion continua).\n"
|
|
|
+fi
|
|
|
+
|
|
|
#Permissions
|
|
|
chown www-data:www-data $backupOutput
|
|
|
-chmod o= $backupOutput
|
|
|
+chmod 640 $backupOutput
|
|
|
|
|
|
#Remove files older than 15 days
|
|
|
printf "Eliminando backups antiguos (+15 dias)\n"
|