Help - Search - Members - Calendar
Full Version: Restoring Cpanel from old drive after crash or hack
The Planet Forums > Control Panels > cPanel/WHM > Cpanel/WHM HOWTOs
Pages: 1, 2, 3
Pimpenstein
So your cpanel server got hacked or crashed? Lots of that going around these days. And if you didn't have cpanel backups of all your sites, then your only option is to copy from the old drive... heres the basics..

commands to be executed from root shell preceded by #

Order restore from rackshack.

In trouble ticket specify to leave the old drive in

Once the restore is done, SSH in to box..

mount the old / partition as old (on RS boxes almost always /dev/hdb3)

# mount /dev/hdb3 /old

run chkrootkit to make sure you don't copy back infected files.. http://www.chkrootkit.org/

now we can start copying back data from the old drive

# rsync -vrplogDtH /old/usr/local/apache/conf /usr/local/apache
# rsync -vrplogDtH /old/var/named /var
# rsync -vrplogDtH /old/home/* /home
# rsync -vrplogDtH /old/usr/local/cpanel /usr/local
# rsync -vrplogDtH /old/var/lib/mysql /var/lib
# rsync -vrplogDtH /old/var/cpanel /var
# rsync -vrplogDtH /old/usr/share/ssl /usr/share
# rsync -vrplogDtH /old/var/ssl /var
# rsync -vrplogDtH /old/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
# rsync -vrplogDtH /old/var/log/bandwidth /var/log
# rsync -vrplogDtH /old/usr/local/frontpage /usr/local
# rsync -vrplogDtH /old/var/spool/cron /var/spool
# rsync -vrplogDtH /old/root/.my.cnf /root
# rsync -vrplogDtH /old/etc/httpd/conf/httpd.conf /etc/httpd/conf
# rsync -vrplogDtH /old/etc/sysconfig/network /etc/sysconfig

then change to the old etc, and execute all on one line ...

# cd /old/etc

# rsync -vrplogDtH 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

well I hope I got everything... after you move all that stuff you will find yourself fixing up little things here and there....

I recomend updating cpanel afterwards .. /scripts/upcp .. /scripts/updatenow .. /scripts/sysup .. /scripts/fixeverything

update exim .. /scripts/exim4

Once everything works.. make sure you don't get 0wn3d again...
update apache .. /scripts/easyapache
update kernel to latest (plenty of howto's on these forums)
mount /tmp as noexec (and symlink /var/tmp to /tmp)
phenx
I would first reccomend running a chkrootkit, and other exploit checks before simply copying data over from drive to drive, or you might inadvertantly copy the exploit/rooted files back over to your drive.

Just my 2 cents
Pimpenstein
Yea, got point [IG], I will update the post.
jdatwood
I successfully moved about 30 accounts over to our new server after being hacked but one of them just won't move over. When I'm trying to move it over using WHM it's giving me an error

Here is what's going on... the other 30 went over with no problem.
QUOTE
Attempting to copy jdatwood from 209.61.xxx.xxx  

Attemping to package account...
Copying Mail files....Done
Copying frontpage file....Done
Copying proftpd file....Done
Copying www logs.............
Done
Grabbing mysql dbs...Done
Grabbing mysql privs...Done
Copying mailman lists....Done
Copying mailman archives....Done
Copying homedir........................
...............
...............
...............
...............
...............
...............
...............
...............
Copying cpuser file.......Done
Copying crontab file.......Done
Copying quota info.......Done
Storing Subdomains....
Done
Storing Parked Domains....
Done
Storing Addon Domains....
Done
Copying password.......Done
Copying shell.......Done
Creating Archive .......
...............
...............
...............
...............
...............
...............
...............
...............
...............
...............
Timeout ...
Attemping to package account...
Copying Mail files....Done
Copying frontpage file....Done
Copying proftpd file....Done
Copying www logs.............
...............
Done
Grabbing mysql dbs...Done
Grabbing mysql privs...Done
Copying mailman lists....Done
Copying mailman archives....Done
Copying homedir....cp: cannot create directory `/home/cpmove-jdatwood/homedir': No such file or directory
Done
Copying cpuser file.......Done
Copying crontab file.......Done
Copying quota info.......cp: cannot create regular file `/home/cpmove-jdatwood/cp': No such file or directory
cp: cannot create regular file `/home/cpmove-jdatwood/cron': No such file or directory
Done
Storing Subdomains....
Done
Storing Parked Domains....
Done
Storing Addon Domains....
Done
Copying password.......Done
Copying shell.......Done
Creating Archive ....Done
tar: cpmove-jdatwood: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
Remote file is: /home/cpmove-jdatwood.tar.gz
Copying archive...
cpmove-jdatwood.tar. 100% |*****************************|    45       00:00    

Done
Verifying tarball checksum.....Checksum Matches (Actual username is jdatwood)!
Tarball copy ok!
Extracting tarball....Done
Extracting Domain....Done
Sorry, the copy failed.  Unable to find the cpanel user file
Account Restore Failed...
jdatwood
Anyone have any ideas why I'm unable to transfer this 1 account?
booger
Unless I am mistaken, it has something to do with the dash in the name.
Habby
will this work for transfering data that is in a redhat 9 disk into a new red hat enterprise disk?
Cloak
QUOTE
Originally posted by Habby
will this work for transfering data that is in a redhat 9 disk into a new red hat enterprise disk?


In theory it should. I will let you know in practice in a couple hours when I'm done moving mine over. The only thing I see that will need to be changed is the httpd.conf file, it will be in /usr/local/apache/conf/httpd.conf
saniyogi
I performed these steps but it looks like DNS isn't resolving the sites that are located on the server.

In addition, Im getting multiple email messages from the server that say:

apache failed @ Wed Jan 21 02:51:08 2004. A restart was attempted automagicly.

And I can't access the server via SSH. I'm not entirely sure what the problem could be.

Any log files I can check to see how/why apache is crashing?
AdamTuttle
Same here Apache wont start, and also none of my users are showing up in WHM.
Pimpenstein
check your error_log to see why apache won't start
saniyogi
I found out that it was because the old installation of cpanel had tomcat installed and when restarting, it didn't because it was looking for mod_jk.c. Installing tomcat stuff helped.
Pimpenstein
Sorry, I should have added that to the tutorial.. if you have mod_jk and/or apache::asp installed you need to reinstall them also, or you will have errors in the httpd.conf.. you can run /etc/rc.d/init.d/httpd --configtest to see where the config errors are if your apache doesa not start
WebHS
I have no users showing up in WHM!!!!:confused: :confused:
nettigritty
that doesnt sound very good. I am about to do a restore post suckit.

anyone else not seeing accounts in WHM
nettigritty
anything else specific I should do to prevent the rootkit making its way back to the new hdd ?

/sbin/init was infected ..
nettigritty
I guess I'll answer that myself. Recovered from suckit successfully. everything showing in WHM.

one thing please add above the mount line in the HOWTO:

mkdir old
kris1351
When you backup the named.tar.gz to /var/named all of the db files look great. DNS is actually responding but WHM does not see the host names on the left side of the screen. Everything on the right shows up for CNAME, A, NS etc. I have changed ownership to named.named of the named and named.db files/dir but no luck. Any help on this would be great. We are recovering from the biggest EV1 screwup ever.
aldalil
And I can't access the server via SSH.

how can I solve this ? icon_sad.gif
aldalil
SSH is working now ..thanx RS support team ..
famehost
Hi,

will this procedure work with moving from RH9 to a new RHEL image on a new disk?
nettigritty
probably with little or no modification. you could check with Live Chat .. ?
famehost
Yeah I already did and was advised to submit a ticket which I did.

It mentions this post *might* be able to help but I want to make sure it wont mess anything up. I currently have 2 physical disks in the server with the secondary mounted as /backups containing the cpbackup files.

I was going to mount the new RHEL drive image as primary, make the current primary a third drive and mount it as /old for 48 hours , leave the current secondary drive as the secondary drive mounted as /backups and then follow the above procedures. When I finished I was going to ask them to remove the third drive which was my old primary.

Do you think this will work ok?
nettigritty
QUOTE
Originally posted by famehost
Yeah I already did and was advised to submit a ticket which I did.

It mentions this post *might* be able to help but I want to make sure it wont mess anything up.  I currently have 2 physical disks in the server with the secondary mounted as /backups containing the cpbackup files.

I was going to mount the new RHEL drive image as primary, make the current primary a third drive and mount it as /old for 48 hours , leave the current secondary drive as the secondary drive mounted as /backups and then follow the above procedures.  When I finished I was going to ask them to remove the third drive which was my old primary.

Do you think this will work ok?


thats exactly what i did for RH7.3 to 9 . worked great. Hope it works out for you..
famehost
If anyone has actually done this to upgrade Redhat 9 to Redhat Enterprise I would be very grateful to hear if it worked out ok.
Lippy
Quick question.

If I preform a backup of all accounts and then order a new Hardrive(upgrade 80 GB drive). Have them preform a restore to RHE with Cpanel on it. Then do restore accounts from backup using the backups I made will cpanel create all needed files, DNS entries, databases, and site related stuff?

Thanks to anyone who answers.
nettigritty
Yes it restores all that but we still dont know for sure about RHE. Someone who's tried it needs to confirm ..
aldalil
CGI scripts are not working after driver mount & CPanel restoring


Any idea icon_sad.gif ?
nettigritty
whats the error ?
aldalil
error message is: " No Username given " !
nettigritty
that might be something with the script ?
aldalil
may be with the script ..but what is amazed is that all CGI scripts are not working .......

by the way ... when RS Team restore the system...they installed RedHat 9 instead of that one 7.3 (old operating system)

so ..is there a different path or something like that in Redhat 9 !!!
nettigritty
they did exactly the same thing for me ! icon_smile.gif

lemm just try out a cgi script.. hang on..
nettigritty
the cgi-sys scripts are workin fine .. did you try that (from cpanel) ?

try:

aldalil
I've got a green counter ....

so ... do u wanna say that "cgi is working well" ?

but what about other scripts ... :rolleyes:
nettigritty
Try this ..

QUOTE

Testing CGI/Perl on your domain account

Here is a very basic 3-line script written in Perl. Copy the text below into Notepad, or other text editor. Using ASCII format, place it into your cgi-bin folder, and name it 'test.cgi'. Set permissions to 755 (rwx rx rx), and launch it in your browser by going to \"www./cgi-bin/test.cgi\".  

You should see a line of text saying \"Hello world!\" if it works properly. NOTE: if the test script works, then the problem is not with the servers or your domain account, it is in the script.  

-- snip below this line --
#!/usr/local/bin/perl
print \"Content-Type: text/html\n\n\";
print \"Hello world!\n\";  
-- snip above this line --
aldalil
ya ... it is workign well ...
I get :"Hello world!"


mmmmmmmmmm

so ..what do u think the problem is .. ?
before I forget ...thanx alot nettigritty icon_wink.gif

icon_smile.gif
nettigritty
thats cool icon_smile.gif

what script is it thats givin u the error ?
aldalil
mmmmmmm
the script is "Entropy Banner" from the CGI Center in CPanel
it offers banners rotating ... icon_sad.gif
NAPPA
I executed the scripts, but I dont' see my packages. Do I need to copy the files again ? Is there something missing in the instructions. I have all the files, and folder. And after much trouble with some of the permissions and usergroups, I've fixed them up. But the Packages is one aspect I've not managed to fix. Can some one help . Thanks icon_smile.gif
Goodspeed
But I've got just one question. How can I add all users account with data? I need to download whole user folder from old drive to new?
Thank you!
alanor
QUOTE
Originally posted by Goodspeed
But I've got just one question. How can I add all users account with data? I need to download whole user folder from old drive to new?
Thank you!


I have this problem too... my server restored and old drive added now all sites working for only 6-7 hours. Because old drive will be removed...

I don't know how can i backup all users data, mysql.... to new drive ????

Can i back in WHM to new drive so can i restore backup?

I am thinking orde new redhat enterprise server. I am thinking all my data copy to there from old drive WHM. But i don't know this will be working good?
elleryjh
I followed the instructions above, but incoming and outgoing mail are failing.
I'm getting tons of errors in exim_rejectlog of these 2 types:
2004-06-19 14:51:34 H=(***-136.rb.lax.centurytel.net) [69.179.**.***] F=<*****@midcoast.com> rejected RCPT <********@********.com>:
2004-06-19 15:12:55 H=(218-168-50-92.dynamic.hinet.net) [218.168.**.**] F=<*********@yahoo.com> rejected RCPT <******@*********.net>: Unrouteable address

earlier I was getting this message:
2004-06-19 13:22:54 H=(************.*************.com) [67.166.**.***] F=<****@*************.com> temporarily rejected RCPT <****@*************.com>: failed to open /etc/localaliases for linear search: No such file or directory

Since /old/etc/localaliases was an empty file, I created it as an empty file. Now I am getting the first two messages I mentioned and all mail seems to be failing.
Insyder
You so just saved my butt a lot of work. I appreciate it tons man. Everything worked great!

7.3 -> RHE3
alanor
QUOTE
Originally posted by Pimpenstein

# rsync -vrplogDtH /old/usr/local/apache/conf /usr/local/apache
# rsync -vrplogDtH /old/var/named /var
# rsync -vrplogDtH /old/home/* /home
# rsync -vrplogDtH /old/usr/local/cpanel /usr/local
# rsync -vrplogDtH /old/var/lib/mysql /var/lib
# rsync -vrplogDtH /old/var/cpanel /var
# rsync -vrplogDtH /old/usr/share/ssl /usr/share
# rsync -vrplogDtH /old/var/ssl /var
# rsync -vrplogDtH /old/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
# rsync -vrplogDtH /old/var/log/bandwidth /var/log
# rsync -vrplogDtH /old/usr/local/frontpage /usr/local
# rsync -vrplogDtH /old/var/spool/cron /var/spool
# rsync -vrplogDtH /old/root/.my.cnf /root
# rsync -vrplogDtH /old/etc/httpd/conf/httpd.conf /etc/httpd/conf
# rsync -vrplogDtH /old/etc/sysconfig/network /etc/sysconfig

then change to the old etc, and execute all on one line ...  

# cd /old/etc

# rsync -vrplogDtH 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


I did make this. I guess everything is ok without sites working. Any domain not working and i don't see any domain in Account List.

What is problem?
TDI
After folling these steps I'm unable to get cPanel to show the users databases. And their sites aren't connecting to them.

Any ideas for a fix?

*edit*
I took the server down for a quick reboot since I hadn't done that...

shorty after coming back online the sites were accessing the databases fine and they're showing up in cPanel now.
*/edit*
TDI
There is a problem I am suffering from - email is not working on this server.

I did resync cPanel and update exim - but it just won't work. No error messages either, just not happening.

Ideas?

Thanks.
aldalil
QUOTE
Originally posted by TDI
There is a problem I am suffering from - email is not working on this server.

I did resync cPanel and update exim - but it just won't work. No error messages either, just not happening.

Ideas?

Thanks.


I did the following:

cd /scripts
dir
./fixeverything
cd /scripts
dir
./upcp
ls -la
./buildeximconf
./checkexim.pl
./fixhome
/scripts/mailperm
/scripts/fixmailandakopia
/scripts/fixvaliases
/scripts/mailperm
./scripts/mailperm
/etc/rc.d/init.d/cpanel restart
/etc/rc.d/init.d/cpanel restart
cd /scripts
dir
ls -la
./rebuildeximbsd
/scripts/exim4
/scripts/exim4
ps -aux
cd /scripts
./fixeverything


and it solved the problem icon_smile.gif

you can do it .. no risk for that
TDI
Ugh - that didn't work either.

Thanks for replying though icon_smile.gif
aldalil
did u check your DNS configurations ? nameservers,ips ...etc.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.