The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Recover server from Disk Image

Discussion in 'Data Protection' started by damtech, Jul 28, 2015.

  1. damtech

    damtech Member

    Joined:
    Jan 2, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    My CentOS server went down this morning. My provider has told me that its likely because of a fialed update script. Upon rebooting the server we discovered the boot folder on thr server was actually empty!

    No idea how, but the situation I am in now is that I have a rebuilt server, that is currently a fresh install of CPanel / WHM. I also have the old disk drive, which is fine other than empty boot folder.

    I now need to some how get the data (website files, email accounts, databases, DNS entries etc) from the broken disk, to the clean image.

    Any help would be greatly appreciated. I understand that this is not an ideal, and backup files would be better, but this is the situation ive found myself in.
     
  2. Jcats

    Jcats Well-Known Member

    Joined:
    May 25, 2011
    Messages:
    275
    Likes Received:
    31
    Trophy Points:
    28
    Location:
    New Jersey
    cPanel Access Level:
    DataCenter Provider
    Ouch, none of it should really be a problem other than the databases.

    I would most likely create all the accounts via WHM then use rsync to sync up the home directories, this will take care of the web site files, emails, forwarders, etc.

    The DNS entries shouldn't be an issue either, would just rsync them as well.

    As long as you create the accounts using the same usernames, you can do something like this

    Syncing homedirs
    Code:
    for i in `ls -I . -I .. /var/cpanel/users` ; do echo Syncing account $i now ; rsync -ahvz /olddrive/home/$i/ /home/$i/ ; done
    
    DNS zones
    Code:
    rsync -ahvz /olddrive/var/named/*.db /var/named/ ; service named reload
    
    I'm not to sure if that will cause issues with serials but maybe someone else can comment on that.

    You will want to make sure all ownership / permissions are in order after syncing the homedirs:
    Code:
    for i in `ls -I . -I .. /var/cpanel/users` ; do chown -R $i: /home/$i/public_html ; chown $i:nobody /home/$i/public_html ; find /home/$i/public_html/ -type f -exec chmod 644 {} \; ; find /home/$i/public_html/ -type d -exec chmod 755 {} \; ; done
    
    The databases, I'd probably throw up a VPS running the same version as your previous MySQL server, and just drop your /olddrive/var/lib/mysql/ into that vm's mysql data directory, restart and hope they work, then you can mysqldump from there.

    You would need to do the mysql database itself as well otherwise you would have to manually add back all the users / permissions.

    Hopefully this gets you started at least.
     
  3. damtech

    damtech Member

    Joined:
    Jan 2, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thats great thanks!

    When im copying the home dir, its doing a file: useraccoutname/.spamassassin/bayes_toks.broken.1437960356

    Trouble is this file must be massive, and it seems to be trying to expand it when syncing, so it fills the hard drive, stopes because the disk is full, then releases all the space again.

    Is there a way to exclude this file/folder?
     
  4. damtech

    damtech Member

    Joined:
    Jan 2, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    It's OK.
    I got past it. Just removed the file and it continued no problem
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    I'm happy to see the transfer was able to proceed. Could you confirm if the server files have now been successfully restored?

    Thank you.
     
  6. damtech

    damtech Member

    Joined:
    Jan 2, 2013
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I'm happy to see the issue is now resolved. Note that it's a good idea to keep backups of your accounts as generated through the cPanel backup options to avoid this problem in the future.

    Thank you.
     
Loading...

Share This Page