Cpanel Backup In Rescue Mode

“NOTE:  

In this guide, the server is in rescue mode with Debian OS and the actual server was in Centos 6.8. There are two scenarios, 1.Rescue mode (debian os) 2.Chroot (centos 6.8 under /mnt)

In this scenario the “/ ” and all other partitions (like /home) are under same drive, you have to mount the drives according to your server partition 

This method will not work on Centos 7 and later versions because the systemctl command will not work in chroot environment.

Rescue mode

  • Login to the rescue server using ssh or putty (ssh root@ip.add.re.ss)
  • Check  the (attached) old disk  with lsblk command and mount it on /mnt

#lsblk

for example if the disk name is /dev/sdb1
#mount /dev/sdb1 /mnt

  • Now the old disk has been mounted on /mnt
  • Check /mnt/dev /mnt/sys /mnt/proc directories under /mnt, it should be empty (the “/mnt/dev” will have null file)
  • Bind the directories from rescue server to /mnt environment as follows

# mount –bind /proc /mnt/proc

# mount –rbind /dev /mnt/dev

# mount –bind /sys /mnt/sys 

Chroot environment

  • Create screen with screen command

#screen -S chroot

  • From the screen chroot into “/mnt” with following command

#chroot /mnt

  • Now, you are connected with the old disk, you could see the actual server’s disk or list the files with ls -al command to verify the disk.

#cat /etc/redhat-release

CentOS release 6.8

  • Start the services like cpanel and mysql

#service cpanel start

#service mysql start

  • After starting the services, you can take backup with “/scripts/pkgacct” or “/usr/local/cpanel/bin/backup” or “/scripts/cpbackup”
  • Take the list of Cpanel users which you want to take backup and initiate with below script. The Cpanel usernames will be in “/etc/userdomains” file so, now we are going to get the list.

#cat /etc/userdomains | cut -d”:” -f2 | sort -n | uniq >> users.txt

  • Open the file “users.txt” check if there is any blank spaces and use below command to remove blank spaces

#sed “s/ //g” users.txt

#for i in `cat users.txt`; do /scripts/pkgacct $i; done

  • The backup should be in progress
  • Detach the screen with Ctrl + ad

D KarthiKeyan