CPANEL IS NOT ABLE TO SUPPORT FAILING HARD DRIVES OR HARD DRIVE RECOVERY. THIS IS ONLY A GUIDE. PLEASE TAKE CARE WITH YOUR DATA AND WE ARE NOT RESPONSIBLE FOR ANY DATA LOSS.
Sometimes there are cases when you do not have backups available and your hard drive has crashed. This page is meant to help as a guide in using pkgacct to backup the files from the failed drive.
Steps:
1) Setup old root directory in chroot.
2) Mount /proc, /dev and /sys into the chroot.
3) Enter the chroot in screen
4) Get environmental information from the old server
5) Start services needed by pkgacct
6) Package the accounts
7) Exit chroot and clean up
8) Done!
1) The first step is to get the old server's root directory set up. Any directory is fine as long as the /home and other system partitions are mounted correctly within. For the example, below assumes that the crashed root filesystem is mounted on /mnt/chroot/, and the home partition is mounted in /mnt/chroot/home. If the drive has more system partitions they also need to be mounted. You should be able to make sure those are mounted by using these commands.
Check /etc/mtab to ensure that system partitions are mounted correctly inside the chroot folder (ie. /mnt/chroot/).
2) Mount the proc, dev, and sys filesystems into the chroot folder:
Then verify that everything is mounted.
3) Enter a chroot and use screen, because if you get disconnected you will lose the chroot. If mysql is running in the chroot, leaving it unexpectedly by not using screen could cause INNODB issues. The chroot will now make /mnt/chroot/ into / as if you were booted into the crashed disk.
4) Now that were inside the chroot we need to get our environmental information from the old server. This is accomplished with the following command.
5) Start any services needed for pkgacct. At a minimum, this requires that MySQL be started otherwise the webmail databases will cause pkgaccct to fail. People using PGSQL will also need that started as well.
6) Now, we can package the accounts. Make sure that at least two times the used space is free. If not you may run into a full disk situation by packaging the accounts.
It should place the backups in /mnt/chroot/home/.
7) Thats it! Now, you should just need to scp or rsync them over to the new server or disk and restore them. Then, it's time to clean up. To leave the chroot, stop MySQL and PgSQL so that they exit cleanly. Then leaving bash should exit the chroot, allowing you to end the session.
8) You're done!
Sometimes there are cases when you do not have backups available and your hard drive has crashed. This page is meant to help as a guide in using pkgacct to backup the files from the failed drive.
Steps:
1) Setup old root directory in chroot.
2) Mount /proc, /dev and /sys into the chroot.
3) Enter the chroot in screen
4) Get environmental information from the old server
5) Start services needed by pkgacct
6) Package the accounts
7) Exit chroot and clean up
8) Done!
1) The first step is to get the old server's root directory set up. Any directory is fine as long as the /home and other system partitions are mounted correctly within. For the example, below assumes that the crashed root filesystem is mounted on /mnt/chroot/, and the home partition is mounted in /mnt/chroot/home. If the drive has more system partitions they also need to be mounted. You should be able to make sure those are mounted by using these commands.
Code:
-bash-4.1# mount --bind / /mnt/chroot/
-bash-4.1# mount --bind /home/ /mnt/chroot/home/
Code:
-bash-4.1# grep chroot /etc/mtab
/ /mnt/chroot none rw,bind 0 0
/home /mnt/chroot/home none rw,bind 0 0
Code:
-bash-4.1# mount --bind /proc /mnt/chroot/proc
-bash-4.1# mount --bind /dev /mnt/chroot/dev
-bash-4.1# mount --bind /sys /mnt/chroot/sys
Code:
-bash-4.1# grep chroot /etc/mtab
/ /mnt/chroot none rw,bind 0 0
/proc /mnt/chroot/proc none rw,bind 0 0
/home /mnt/chroot/home none rw,bind 0 0
/proc /mnt/chroot/proc none rw,bind 0 0
/dev /mnt/chroot/dev none rw,bind 0 0
/sys /mnt/chroot/sys none rw,bind 0 0
Code:
bash-4.1# screen
bash-4.1# chroot /mnt/chroot /bin/bash -l
bash-4.1# export PS1="{chrooted}$PS1"
{chrooted}bash-4.1#
Code:
{chrooted}bash-4.1# source /etc/environment && source /etc/profile
Code:
{chrooted}bash-4.1# service mysql start
Starting MySQL SUCCESS!
Code:
{chrooted}bash-4.1# cd /var/cpanel/users
{chrooted}bash-4.1# for i in `ls -1 *`; do /scripts/pkgacct $i; done
7) Thats it! Now, you should just need to scp or rsync them over to the new server or disk and restore them. Then, it's time to clean up. To leave the chroot, stop MySQL and PgSQL so that they exit cleanly. Then leaving bash should exit the chroot, allowing you to end the session.
Code:
{chrooted}bash-4.1# service mysql stop
{chrooted}bash-4.1# umount {/proc,/dev,/sys}
{chrooted}bash-4.1# exit
logout
bash-4.1# exit
[screen is terminating]