Right, if for some reason someone managed to rm -Rf your root or etc directory,
this may help you to restore a fair amount of your cpanel files. back into cpanel.
The process basically involves copying the old files into a new installation of cpanel (same ip as the license from the previous, or just replace the license afterwards)
Then, copying over old mysql files / folders, and using cpanel to package up what files i thinks it can find into a cpmove,
then restoring the cpmove folder back again to pull all the data back into cpanel properly.
THIS IS NOT RECCOMENDED IF YOU ALREADY HAVE ANY CPBACKUP OR CPMOVE FILES.
I accidentally restored one or two of these which turned out to be old onmes, and obviously, all the old data was imported back in and overwritten the new data.
So either restore them using cpanel normally, or move the old cpbackup / move files elsewhere.
cpadduser.sh contents: (DEF$1 is the password, so for user cake, the password would become DEFcake. to manually add passwords when running the script, change DEF$1 to $2.)
1:
use rysnc from the old home to the new home to preserve as much as possible in terms of permissions etc.
if you want secure rsync across servers, then ensure to use ssh.
e.g below:
/home/oldhomefiles is my files from home directory,
/home/otherfiles is any other files/folders that cpanel uses.
do not worry if you do not have all of the folders/files that i put in /home/otherfiles/ to sync to the new installation, i didnt have all of them either.
cd to the old etc directory:
And copy some files from here:
2:
3:
4:
copy cpadduser(above) into a new file (cpadduser.sh)
use cpadduser.sh to restore accounts.
passwords can be set by altering the cpadduser script to take a second variable for password.
5:
If permissions are rather broken, try some / all of the following:
any directories requiring 777 (e.g. whmcs templates_c) will have to have the permissions changed back again afterwards.
Hopefully this has been of some help to some people, after spending over 19 hours solid trying to restore 120 accounts this is what i managed to come up with.
Not everything may run, some files may not be found etc, but it might get you somewhere.
I take no responsibilty for any dataloss or currupt cpanel accounts from anyone using this,
however with most people when you say "my root drive is broken, how do i restore my cpanel accounts, my backups are old / nonexistent?" they say "You Can't!"
Good luck! If anyone would like to make this process easier, or knows a way to restore account passwords, or a better way for this process, please contact me at [email protected].
Thanks.
this may help you to restore a fair amount of your cpanel files. back into cpanel.
The process basically involves copying the old files into a new installation of cpanel (same ip as the license from the previous, or just replace the license afterwards)
Then, copying over old mysql files / folders, and using cpanel to package up what files i thinks it can find into a cpmove,
then restoring the cpmove folder back again to pull all the data back into cpanel properly.
THIS IS NOT RECCOMENDED IF YOU ALREADY HAVE ANY CPBACKUP OR CPMOVE FILES.
I accidentally restored one or two of these which turned out to be old onmes, and obviously, all the old data was imported back in and overwritten the new data.
So either restore them using cpanel normally, or move the old cpbackup / move files elsewhere.
cpadduser.sh contents: (DEF$1 is the password, so for user cake, the password would become DEFcake. to manually add passwords when running the script, change DEF$1 to $2.)
Code:
---------------------
#!/bin/bash
set -u
if [ "$1" = "-help" ]
then
echo "Use: ./cpadduser.sh username"
else
/scripts/adduser "$1" /home DEF$1
/scripts/pkgacct $1
/scripts/restorepkg --force /home/cpmove-$1.tar.gz
chown -R $1:nobody /home/$1
chmod -R 0755 /home/$1/public_html
/usr/local/cpanel/bin/rebuild_phpconf 5 none dso 1
/scripts/updateuserdomains
exit 0
fi
---------------------
1:
use rysnc from the old home to the new home to preserve as much as possible in terms of permissions etc.
if you want secure rsync across servers, then ensure to use ssh.
e.g below:
/home/oldhomefiles is my files from home directory,
/home/otherfiles is any other files/folders that cpanel uses.
do not worry if you do not have all of the folders/files that i put in /home/otherfiles/ to sync to the new installation, i didnt have all of them either.
Code:
rsync -vrplogDtH -e ssh /home/oldhomefiles/* [email protected]:/homersync -vrplogDtH -e ssh /home/otherfiles/usr/local/cpanel [email protected]:/usr/local
rsync -vrplogDtH -e ssh /home/otherfiles/var/lib/mysql [email protected]:/var/lib
rsync -vrplogDtH -e ssh /home/otherfiles/var/cpanel [email protected]:/var
rsync -vrplogDtH -e ssh /home/otherfiles/usr/share/ssl [email protected]:/usr/share
rsync -vrplogDtH -e ssh /home/otherfiles/var/ssl [email protected]:/var
rsync -vrplogDtH -e ssh /home/otherfiles/usr/local/cpanel/3rdparty/mailman [email protected]:/usr/local/cpanel/3rdparty
rsync -vrplogDtH -e ssh /home/otherfiles/var/log/bandwidth [email protected]:/var/log
rsync -vrplogDtH -e ssh /home/otherfiles/usr/local/frontpage [email protected]:/usr/local
rsync -vrplogDtH -e ssh /home/otherfiles/var/spool/cron [email protected]:/var/spool
rsync -vrplogDtH -e ssh /home/otherfiles/usr/local/apache/conf [email protected]:/usr/local/apache
rsync -vrplogDtH -e ssh /home/otherfiles/var/named [email protected]:/var
rsync -vrplogDtH -e ssh /home/otherfiles/root/.my.cnf [email protected]:/root
rsync -vrplogDtH -e ssh /home/otherfiles/etc/httpd/conf/httpd.conf [email protected]:/etc/httpd/conf
Code:
cd /otherfiles/etc
Code:
rsync -vrplogDtH -e ssh secondarymx domainalias valiases vfilters exim* proftpd* pure-ftpd* passwd* group* *domain* *named* wwwacct.conf cpupdate.conf quota.conf shadow* *rndc* ips* ipaddrpool* ssl hosts /etc
2:
Code:
/scripts/upcp/scripts/updatenow/scripts/sysup/scripts/exim4
/scripts/easyapache/scripts/securetmp/scripts/fixeverything
/scripts/mysqlup --force/usr/local/cpanel/bin/updatephpmyadmin --force
/scripts/upcp --force/usr/local/cpanel/cpkeyclt
Code:
/scripts/restartsrv httpd
/scripts/restartsrv cpanel
/scripts/restartsrv mysql
/scripts/restartsrv named
/scripts/restartsrv exim
copy cpadduser(above) into a new file (cpadduser.sh)
use cpadduser.sh to restore accounts.
Code:
./cpadduser.sh
5:
If permissions are rather broken, try some / all of the following:
any directories requiring 777 (e.g. whmcs templates_c) will have to have the permissions changed back again afterwards.
Code:
[I]
/scripts/postsuexecinstall
/scripts/chownpublichtmls
cd /home find -perm 777 -exec chmod 755 {} \; -print
find -perm 666 -exec chmod 644 {} \; -print
/scripts/fixsuexeccgiscripts[/I]
Hopefully this has been of some help to some people, after spending over 19 hours solid trying to restore 120 accounts this is what i managed to come up with.
Not everything may run, some files may not be found etc, but it might get you somewhere.
I take no responsibilty for any dataloss or currupt cpanel accounts from anyone using this,
however with most people when you say "my root drive is broken, how do i restore my cpanel accounts, my backups are old / nonexistent?" they say "You Can't!"
Good luck! If anyone would like to make this process easier, or knows a way to restore account passwords, or a better way for this process, please contact me at [email protected].
Thanks.