Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - beer73

Pages: [1]
1
Mod_Security / Re: Found another rule with the same id
« on: October 08, 2017, 11:34:35 AM »
In my case, maybe due to some update (I dont know) I had duplicated these last 3 lines in my httpd.conf file which caused me the error "FOUND ANOTHER RULE WITH THE SAME ID":

Code: [Select]
Include /usr/local/apache/conf/sharedip.conf
Include /usr/local/apache/conf.d/*.conf
ExtendedStatus On

Include /usr/local/apache/conf/sharedip.conf
Include /usr/local/apache/conf.d/*.conf
ExtendedStatus On

Removing duplicate lines everything works correctly.

2
E-Mail / Re: /usr/sbin/tmpwatch: No such file or directory
« on: April 21, 2017, 07:08:31 AM »
In my case I solved it with

yum install tmpwatch


3
Hello, until a more suitable solution, I want to share my two backup restore scripts.
When you must restore a big number of domains, It is a great help.

Note: It is assumed that you previously created all users and databases to restore. The restore files script will keep owner and permissions, and the mysql script will drop all tables from database without delete the database (keeping user permissions).

Script 1: restore_backup.sh

Code: [Select]
#!/bin/bash
#
# RESTORE BACKUP SCRIPT from central backup repository
# http://centos-webpanel.com
#

# Root folder of backups repository (change accordly)
BACKUPROOT="/backups"

if [[ $# -ne 3 ]]; then
   echo "Usage: restore_backup -d|-w|-m username webfolder"
   echo "       where d=daily, w=weekly, m=monthly"
   echo "Example: restore_backup -d user1 public_html"
   echo "         will restore public_html folder files for user1 from daily backup repository"
   exit 1
fi

case "$1" in
   -d)
     BACKUPTYPE="daily"
     ;;
   -w)
     BACKUPTYPE="weekly"
     ;;
   -m)
     BACKUPTYPE="monthly"
     ;;
   *)
     echo "Usage: restore_backup -d|-w|-m username webfolder"
     echo "       where d=daily, w=weekly, m=monthly"
     echo "Example: restore_backup -d user1 public_html"
     echo "         will restore public_html folder files for user1 from daily backup repository"
     exit 1
esac

USERNAME=$2
WEBFOLDERNAME=$3
GETHOMEDIR=`grep $USERNAME /etc/passwd|awk -F: {'print $6'}`

# Some validations
if [ -z "$GETHOMEDIR" ]; then
   echo "Error: home directory for user $USERNAME not found, you must create the user before restore it's files."
   exit 1
fi
if [ ! -e "$GETHOMEDIR" ];then
   echo "Error: $GETHOMEDIR not exists, you must create the user before restore it's files."
   exit 1
fi
if [ ! -e "$BACKUPROOT" ];then
   echo "Error: $BACKUPROOT not exists, cannot restore."
   exit 1
fi
if [ ! -e "$BACKUPROOT/$BACKUPTYPE" ];then
   echo "Error: $BACKUPROOT/$BACKUPTYPE not exists, cannot restore."
   exit 1
fi
if [ ! -e "$BACKUPROOT/$BACKUPTYPE/$USERNAME" ];then
   echo "Error: $BACKUPROOT/$BACKUPTYPE/$USERNAME not exists, cannot restore it."
   exit 1
fi
if [ ! -e "$BACKUPROOT/$BACKUPTYPE/$USERNAME/$WEBFOLDERNAME" ];then
   echo "Error: $BACKUPROOT/$BACKUPTYPE/$USERNAME/$WEBFOLDERNAME not exists, cannot restore it."
   exit 1
fi

# Delete Webfolder only if it exists
if [ -e "/home/$USERNAME/$WEBFOLDERNAME" ];then
    rm -rf /home/$USERNAME/$WEBFOLDERNAME/
fi

# Restore Backup Files with its permissions
cp -ax $BACKUPROOT/$BACKUPTYPE/$USERNAME/$WEBFOLDERNAME /home/$USERNAME

# Restore owner of files
chown $USERNAME:nobody /home/$USERNAME/$WEBFOLDERNAME
chown -R $USERNAME:$USERNAME /home/$USERNAME/$WEBFOLDERNAME/*

Script 2: restore_mysql.sh

Code: [Select]
#!/bin/bash
#
# RESTORE MYSQL BACKUP SCRIPT from central backup repository
# http://centos-webpanel.com
#
# Note: the database must exist before restored
#

# Root folder of backups repository (change accordly)
BACKUPROOT="/backups"

if [[ $# -ne 3 ]]; then
   echo "Usage: restore_mysql -d|-w|-m username dbname"
   echo "       where d=daily, w=weekly, m=monthly"
   echo "Example: restore_mysql -d user1 db1"
   echo "         will restore user1_db1 mysql database from daily backup repository"
   exit 1
fi

case "$1" in
   -d)
     BACKUPTYPE="daily"
     ;;
   -w)
     BACKUPTYPE="weekly"
     ;;
   -m)
     BACKUPTYPE="monthly"
     ;;
   *)
   echo "Usage: restore_mysql -d|-w|-m username dbname"
   echo "       where d=daily, w=weekly, m=monthly"
   echo "Example: restore_mysql -d user1 db1"
   echo "         will restore user1_db1 mysql database from daily backup repository"
     exit 1
esac

USERNAME=$2
DBNAME=$3
MYSQLPWD=`grep password= /root/.my.cnf|awk -F= {'print $2'}`

# Some validations
if [ ! -e "$BACKUPROOT" ];then
   echo "Error: $BACKUPROOT not exists, cannot restore."
   exit 1
fi
if [ ! -e "$BACKUPROOT/mysql/$BACKUPTYPE" ];then
   echo "Error: $BACKUPROOT/mysql/$BACKUPTYPE not exists, cannot restore."
   exit 1
fi
if [ ! -e "$BACKUPROOT/mysql/$BACKUPTYPE/${USERNAME}_${DBNAME}.sql" ];then
   echo "Error: $BACKUPROOT/mysql/$BACKUPTYPE/${USERNAME}_${DBNAME}.sql not exists, cannot restore it."
   exit 1
fi

# Drop all tables from database
mysqldump -uroot -p"$MYSQLPWD" --add-drop-table --no-data ${USERNAME}_${DBNAME} | grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -uroot -p"$MYSQLPWD" ${USERNAME}_${DBNAME}

# Import mysql backup dump
mysql -uroot -p"$MYSQLPWD" ${USERNAME}_${DBNAME} < $BACKUPROOT/mysql/$BACKUPTYPE/${USERNAME}_${DBNAME}.sql

Corrections and improvements are welcome
Hope it helps.

4
When you delete a user account, the backup user folders should also be eliminated.

Although easily resolved (delete by hand) would be an improvement to add to the user accounts removal script.

Thanks.

Pages: [1]