{"id":31,"date":"2008-03-13T00:08:41","date_gmt":"2008-03-12T17:08:41","guid":{"rendered":"http:\/\/blog.whplus.com\/2008\/03\/13\/restoring-cpanel-from-old-drive-after-crash-or-hack.html"},"modified":"2019-03-21T10:40:27","modified_gmt":"2019-03-21T03:40:27","slug":"restoring-cpanel-from-old-drive-after-crash-or-hack","status":"publish","type":"post","link":"https:\/\/www.whplus.com\/blog\/2008\/03\/13\/restoring-cpanel-from-old-drive-after-crash-or-hack.html","title":{"rendered":"Restoring Cpanel from old drive after crash or hack"},"content":{"rendered":"<p>cPanel Restore Guide<\/p>\n<p>=====================================================================<br \/>\nSo your cpanel server got hacked or crashed? Lots of that going around these days. And if you didn&#8217;t have cpanel backups of all your sites, then your only option is to copy from the old drive&#8230; heres the basics..<\/p>\n<p>commands to be executed from root shell preceded by #<br \/>\n1) Order restore from The Planet. In trouble ticket specify to leave the old drive in<br \/>\n2) Once the restore is done, SSH in to box..<\/p>\n<p>mount the old \/ partition as old (on TP boxes almost always \/dev\/hda3)<\/p>\n<p>root@box# mount \/dev\/hda \/old<\/p>\n<p>run chkrootkit to make sure you don&#8217;t copy back infected files&#8230; <a href=\"http:\/\/www.chkrootkit.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.chkrootkit.org\/<\/a><\/p>\n<p>now we can start copying back data from the old drive<\/p>\n<p>root@box# rsync -vrplogDtH \/old\/usr\/local\/apache\/conf \/usr\/local\/apache<br \/>\nroot@box# rsync -vrplogDtH \/old\/var\/named \/var<br \/>\nroot@box# rsync -vrplogDtH \/old\/home\/* \/home<br \/>\nroot@box# rsync -vrplogDtH \/old\/usr\/local\/cpanel \/usr\/local<br \/>\nroot@box# rsync -vrplogDtH \/old\/var\/lib\/mysql \/var\/lib<br \/>\nroot@box# rsync -vrplogDtH \/old\/var\/cpanel \/var<br \/>\nroot@box# rsync -vrplogDtH \/old\/usr\/share\/ssl \/usr\/share<br \/>\nroot@box# rsync -vrplogDtH \/old\/var\/ssl \/var<br \/>\nroot@box# rsync -vrplogDtH \/old\/usr\/local\/cpanel\/3rdparty\/mailman \/usr\/local\/cpanel\/3rdparty<br \/>\nroot@box# rsync -vrplogDtH \/old\/var\/log\/bandwidth \/var\/log<br \/>\nroot@box# rsync -vrplogDtH \/old\/usr\/local\/frontpage \/usr\/local<br \/>\nroot@box# rsync -vrplogDtH \/old\/var\/spool\/cron \/var\/spool<br \/>\nroot@box# rsync -vrplogDtH \/old\/root\/.my.cnf \/root<br \/>\nroot@box# rsync -vrplogDtH \/old\/etc\/httpd\/conf\/httpd.conf \/etc\/httpd\/conf<br \/>\nroot@box# rsync -vrplogDtH \/old\/etc\/sysconfig\/network \/etc\/sysconfig<\/p>\n<p>then change to the old etc, and execute all on one line &#8230;<\/p>\n<p>root@box# cd \/old\/etc<\/p>\n<p>root@box# 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<\/p>\n<p>well I hope I got everything&#8230; after you move all that stuff you will find yourself fixing up little things here and there&#8230;.<\/p>\n<p>I recomend updating cpanel afterwards:<br \/>\n\/scripts\/upcp &#8211;force<br \/>\n\/scripts\/updatenow<br \/>\n\/scripts\/sysup<br \/>\n\/scripts\/fixeverything<br \/>\n\/scripts\/exim4<br \/>\n\/up2date<\/p>\n<p>Once everything works.. make sure you don&#8217;t get 0wn3d again&#8230;<br \/>\n&#8211; Update Apache AND Kernel to Latest: WHM &gt; Software &gt; Apache Update<br \/>\n&#8211; Mount \/tmp as noexec (and symlink \/var\/tmp to \/tmp)<br \/>\n&#8211; Configure cPanel&#8217;s &#8220;cP Hulk&#8221; system to make sure hacking attempts are stopped<br \/>\n&#8211; Consider installing Mod Security (<a href=\"http:\/\/www.modsecurity.org\/projects\/modsecurity\/apache\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>LINK<\/strong><\/a>)<br \/>\n&#8211; Consider installing ConfigServer Security&amp;Firewall (<a href=\"http:\/\/www.configserver.com\/cp\/csf.html\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>LINK<\/strong><\/a>) (only if you think you can handle it)<br \/>\n&#8211; Consider disabling direct root log in (<a href=\"http:\/\/www.webhostgear.com\/24.html\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>TUTORIAL<\/strong><\/a>) (this will make it so you need to log in as admin and su to root, making one more password for someone to try to figure out)<\/p>\n<p>NOTE: cPanel 11 and later versions of cPanel 10 will regularly update your system software by running up2date, cPanel update, etc.<br \/>\n=====================================================================<\/p>\n<p>Ok, groovy. And to the pro&#8217;s out there, don&#8217;t kill me because of the UI instructions rather than SSH toward the bottom. It&#8217;s to prevent anyone from getting stuck. Plus, those have become much more reliable since this guide was first made.<\/p>\n<p>Source: h**p:\/\/forums.theplanet.com\/index.php?showtopic=38797&amp;view=findpost&amp;p=588605<\/p>\n","protected":false},"excerpt":{"rendered":"<p>cPanel Restore Guide ===================================================================== So your cpanel server got hacked or crashed? Lots of that going around these days. And if you didn&#8217;t have cpanel backups of all your sites, then your only option is to copy from the old drive&#8230; heres the basics.. commands to be executed from root shell preceded by # 1)\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.whplus.com\/blog\/2008\/03\/13\/restoring-cpanel-from-old-drive-after-crash-or-hack.html\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-tutorial"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":2,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":1125,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/31\/revisions\/1125"}],"wp:attachment":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}