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

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 &qu

EKS Cluster and Create CSI Driver to store credentials in AWS Secrets Manager via SecretProviderClass

EKS Cluster | CSI Driver | SecretProviderClass | AWS Secrets Manager Setup EKS Cluster and Manage Credentials at runtime using CSI driver using SecretProviderClass and Secrets Manager Assuming you have Configured/Installed AWS CLI, EKSCTL, KUBECTL, HELM. CSI Basic Information: CSI (Container Storage Interface) widely used as a Storage Technology. Created by Google | Mesosphere | Docker.  It has two two Plugins one runs on the Master Node (Centralized Controller Plugin) and another one on Worker Nodes (Decentralized headless Node Plugin).  CSI communication protocol is gRPC.   The communication between Container Orchestration to Controller Plugin (Master) and to Node Plugin (Worker Node) happens using gRPC .  CSI Drivers : vendor specific compiled into Kubernetes/openshift binaries. To use a CSI driver, a StorageClass needs to be assigned first.  The CSI driver is then set as the Provisioner for the Storage Class. CSI drivers provide three main services, which are: Identity |

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 computer in just a few steps. 1,  Cli