Skip to main content

cPanel backup

#!/bin/sh
monthdate=`date +%d`
todatemysql=`date '+%y%m%d'`
yestermonthmysql=`date -d '1 day ago' '+%y%m%d'`
nowdcpaccess=`date '+%m\/%d\/%Y'`
yesterdcpaccess=`date -d '1 day ago'  '+%m\/%d\/%Y'`
nowdaperror=`date '+%a %b %d'`
yesterdaperror=`date -d '1 day ago' '+%a %b %d'`
nowdmessages=`date '+%b %d'`
yesterdmessages=`date -d '1 day ago' '+%b %d'`
nowdmail=`date '+%Y-%m-%d'`
yesterdmail=`date -d '1 day ago' '+%Y-%m-%d'`
mkdir /root/govrequest/$monthdate


for i in `cat /root/govrequest/accounts`; do

touch /root/govrequest/$monthdate/$i.cpanel.log
touch /root/govrequest/$monthdate/$i.apache.log
touch /root/govrequest/$monthdate/$i.messages.log
touch /root/govrequest/$monthdate/$i.mail.log
#monthly cpbackup
pkgrund=`date +%d`
if [ "$pkgrund" -eq "27" ] || [ "$pkgrund" -eq "30" ];then
mkdir /root/govrequest/$monthdate.cpbackup
/scripts/pkgacct $i /root/govrequest/$monthdate
fi
#monthly mysql log backup
sed -n  '/'$yestermonthmysql'/,/'$todatemysql'/p'  /var/log/mysqld.log | grep $i >> /root/govrequest/$monthdate/$i.mysql.log
#monthly cpanel access log

sed -n  '/'$yesterdcpaccess'/,/'$nowdcpaccess'/p' /usr/local/cpanel/logs/access_log | grep $i >> /root/govrequest/$monthdate/$i.cpanel.log


#monthly apache error log

sed -n  "/$yesterdaperror/,/$nowdaperror/p" /usr/local/apache/logs/error_log | grep $i >> /root/govrequest/$monthdate/$i_apache.log

#monthly messages log

sed -n  "/$yesterdmessages/,/$nowdmessages/p" /var/log/messages | grep $i >> /root/govrequest/$monthdate/$i.messages.log

#monthly mail log

sed -n  '/'$yesterdmail'/,/'$nowdmail'/p' /var/log/exim_mainlog | grep $i >> /root/govrequest/$monthdate/$i.mail.log
done

Comments

Popular posts from this blog

RAID

Check the Raid installed lspci | grep RAID     Software Raid ============== Linux Support For Software RAID Currently, Linux supports the following RAID levels (quoting from the man page): LINEAR RAID0 (striping) RAID1 (mirroring) RAID4 RAID5 RAID6 RAID10 MULTIPATH, and FAULTY. MULTIPATH is not a Software RAID mechanism, but does involve multiple devices: each device is a path to one common physical storage device. FAULTY is also not true RAID, and it only involves one device. It provides a layer over a true device that can be used to inject faults. Install mdadm Type the following command under RHEL / CentOS / Fedora Linux: # yum install mdadm Type the following command under Debian / Ubuntu Linux: # apt-get update && apt-get install mdadm How Do I Create RAID1 Using mdadm? Type the following command to create RAID1 using /dev/sdc1 and /dev/sdd1 (20GB size each). First run fdisk on /dev/sdc and /dev/sdd with " Softwa...

Modsecurity block rule for XMLRPC and wp-login attack

SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134  <Locationmatch "/wp-login.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"  SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"  SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"  SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"  </Locationmatch>  SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000234  <Locationmatch "/xmlrpc.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000235,msg:'ip address blocked for 5 m...