Skip to main content

cPanel Script to Dump Data and RYSNC



cPanel Script to Migrate Data In One Shot

cPanel Script to Migrate Data In One Shot

What Does This Script Do :

"cPanel Migration Script" This script is used to take the Input when you Initiate the Script and Prompts for the Directory to provide and to store the cPanel backup files under the same. Once the backup for the accounts has been done which are mentioned in the file name which is "/root/rohit/24.txt".This File contains the Usernames (cPanel accounts) which needs to be moved from the Source Server to the Target Server.



Once the Backup is done then it uses the command known as "sshpass" to rsync the data from the source server to the target server. In "sshpass" we need to provide the destination server password as an argument to that command, so that it will simultaneously move the accounts without asking for the Password.

Note : SSHPASS can be downloaded from the below mentioned link which is -

http://www.nextstep4it.com/categories/unix-command/sshpass/

However, More Information regarding the Working of the Script is mentioned below -


========================================================================

#Starting of the Script

#!/bin/bash

set -x
AUTHOR="ROHIT PATEL"
FILE=/root/rohit/24.txt
MAIL="rp@rohitpatel.in"
SUBJECT="Migration Status"
Success="Migration Is Success."
Failed="Migration Failed."
Target_IP="75.114.50.34"
Source_IP="89.114.50.15"
NOW=$(date +"%d-%m-%Y")
Time=$(date)

read -p "Enter the Directory Name To Create and Store Backup Files Under It - " BAK

if [ ! -d $BAK ] &&  mkdir -p $BAK
then
echo "Backup Directory Created, which Is "$BAK"."
else
echo "Please Provide Directory Name To Generate Backup To :: $BAK"
exit 1;
fi

ans=$?

if [ $ans !=  0 ]
then
echo "Backup Failed To Start."
else
for i in `cat $FILE`; do sudo /scripts/pkgacct $i $BAK; done
fi

rstat=$?
if [ $rstat -eq 0 ]
then
echo "Backup done for the accounts mentioned in $FILE and the backup files are present under the $Source_IP:$BAK Folder."
else
echo "Backup Failed For the Accounts."
fi

retval=$?
if [ $retval == 0 ]
then
echo "Started with the RSYNC of the data from Source Server : $Source_IP to the Target Server :  $Target_IP `sshpass -p "qwedsa@123" rsync -avHe ssh --progress $BAK root@115.114.50.154:/root/rohit/`"
fi

rp=$?
if test $rp == 0
then
echo $Success On :: Date = $NOW and Time is = $Time | mail -s "$SUBJECT" "$MAIL" && echo "Mail Sent Successfully On :: $NOW and $Time."
else
echo $Failed On :: Date = $NOW and Time is = $Time | mail -s "$SUBJECT" "$MAIL" && echo "Mail Sending Failed On :: $NOW and $Time."
fi

echo -e "\n ..This Script Was Made By "Rohit Patel".. \n"


#END of The Script
========================================================================

NOTE : The above Shell Script will do the following things step wise step -

1, Ask for the Directory to dump the cPanel backup file to the same and if it doesn't exists it will create the same. (Ex. : /rohit/).

Note: This will not work if no Argument is provided is the form of Directory Address when it Prompts for the same and also provide such Directory which doesn't exists and then it will create the same and will proceed further else it will not and exit.

2, Then Takes the input from the File name which is "FILE=/root/rohit/24.txt", this file contains the cPanel Usernames to be dumped.

3, Once the backup for the mentioned accounts done then it will start with the RSYNC process from the Source Server to the Target Server.

4, Once RSYNC is done for the Accounts, then it will send a mail to the concerned Administrator regarding the Migration Status (One needs to edit as per there usage the mail id, source server and target server IP, File Path), whether the Migration was Success or Failure along with the Date and Time on which the Migration was Done.



                               "KEEP CALM AND STAY AWAKE"
  


FEED


Share








SUPPORT


View Rohit Patel's profile on LinkedIn









VISIT COUNTER !!



Comments

Popular posts from this blog

Hacking via Cloning Site Using Kali Linux

Hacking via Cloning Site Using Kali Linux Hacking via Cloning Site Using Kali Linux  SET Attack Method : SET stands for Social Engineering Toolkist , primarily written by  David Kennedy . The Social-Engineer Toolkit (SET) is specifically designed to perform advanced attacks against the human element. SET was designed to be released with the  http://www.social-engineer.org  launch and has quickly became a standard tool in a penetration testers arsenal. The attacks built into the toolkit are designed to be targeted and focused attacks against a person or organization used during a penetration test. Actually this hacking method will works perfectly with DNS spoofing or Man in the Middle Attack method. Here in this tutorial I’m only writing how-to and step-by-step to perform the basic attack , but for the rest you can modified it with your own imagination. In this tutorial we will see how this attack methods can owned your com...

Defacing Sites via HTML Injections (XSS)

Defacing Sites via HTML Injections Defacing Sites via HTML Injections What Is HTML Injection: "HTML Injection" is called as the Virtual Defacement Technique and also known as the "XSS" Cross Site Scripting. It is a very common vulnerability found when searched for most of the domains. This kind of a Vulnerability allows an "Attacker" to Inject some code into the applications affected in order to bypass access to the "Website" or to Infect any particular Page in that "Website". HTML injections = Cross Site Scripting, It is a Security Vulnerability in most of the sites, that allows an Attacker to Inject HTML Code into the Web Pages that are viewed by other users. XSS Attacks are essentially code injection attacks into the various interpreters in the browser. These attacks can be carried out using HTML, JavaScript, VBScript, ActiveX, Flash and other clinet side Languages. Well crafted Malicious Code can even hep the ...

Hacking DNN Based Web Sites

Hacking DNN Based Web Sites Hacking DNN Based Web Sites Hacking DNN (Dot Net Nuke) CMS based websites is based on the Security Loop Hole in the CMS. For using that exploit we will see the few mentioned points which illustrates us on how to hack any live site based on Dot Net Nuke CMS. Vulnerability : This is the know Vulnerability in Dot Net Nuke (DNN) CMS. This allows aone user to Upload a File/Shell Remotely to hack that Site which is running on Dot Net Nuke CMS. The Link's for more Information regarding this Vulnerability is mentioned below -                                  http://www.exploit-db.com/exploits/12700/ Getting Started : Here we will use the Google Dork to trace the sites that are using DNN (Dot Net Nuke) CMS and are vulnerable to Remote File Upload. How To Do It : Here, I an mentioning the few points on how to Search for the existing Vulnerability in DNN. Let'...

Excellent tricks and techniques of Google Hacks

Frontpage.. very nice clean search results listing !! I magine with me that you can steal or know the password of any web site designed by "Frontpage". But the file containing the password might be encrypted; to decrypt the file download the program " john the ripper". To see results; just write in the ( http://www.google.com/ ) search engine the code: "# -FrontPage-" inurl:service.pwd ============================================== This searches the password for "Website Access Analyzer", a Japanese software that creates webstatistics. To see results; just write in the ( http://www.google.com/ ) search engine the code: "AutoCreate=TRUE password=*" ============================================== This is a query to get inline passwords from search engines (not just Google), you must type in the query followed with the the domain name without the .com or .net. To see results; just write in the ( http://www.google.co...

Hacking via BackTrack using SET Attack Method

Hacking via BackTrack using SET Attack Method Hacking via BackTrack using SET Attack  1. Click on Applications, BackTrack, Exploit Tools, Social Engineering Tools, Social Engineering Toolkit then select set.