Recover server from Disk Image
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.
-
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 for i in `ls -I . -I .. /var/cpanel/users` ; do echo Syncing account $i now ; rsync -ahvz /olddrive/home/$i/ /home/$i/ ; done
DNS zonesrsync -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: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.0 -
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? 0 -
It's OK. I got past it. Just removed the file and it continued no problem 0 -
I got past it. Just removed the file and it continued no problem
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.0 -
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. 0
Please sign in to leave a comment.
Comments
6 comments