Skip to main content

Complete WHM backup and restore from CLI

Comments

5 comments

  • cPRex Jurassic Moderator
    Hey there! If your backup also had the option of "Backup system files" selected, you would see a /backup/backup-date/system directory alongside the /backup/backup-date/accounts directory, where the actual domain's data is located. The best and easiest way to restore this data to a new server would be to install the new OS, install cPanel, mount the backup drive, and then restore the accounts through WHM. You'll need to manually restore the files from the /system backup directory one at a time if you'd like to move those configurations over as well. You'll likely find the following links helpful for this situation:
    0
  • Spidey Catalin
    Hey there! If your backup also had the option of "Backup system files" selected, you would see a /backup/backup-date/system directory alongside the /backup/backup-date/accounts directory, where the actual domain's data is located. The best and easiest way to restore this data to a new server would be to install the new OS, install cPanel, mount the backup drive, and then restore the accounts through WHM. You'll need to manually restore the files from the /system backup directory one at a time if you'd like to move those configurations over as well. You'll likely find the following links helpful for this situation:

    Thanks for your reply first. Yes, I have also the `system` folder within my `/backup/backup-date` folder. Just few more details please where I didn't understood completely: 1. install OS ? 2. install WHM from scrach ? 3. mount the current/backup drive ? 4. login to the new WHM ? (should I configure something here since I want to use the old configs? ex. nameservers) 5. what should I try to recover first? system or accounts? 6. as I said, I have a backup of system as well, but I didn't understand exactly what you mean by `manually restore the files from the /system backup directory one at a time`. Should I move the content of `/backup/backup-date/system` to somewhere else specific to the new drive in order to be restored? or how exactly am I going to restore the system? 7. For accounts restoration, will WHM recognize the that I have a specific day backup folder (within my secondary drive) and will just perform the entire user list account restoration? It's also possible that my hosting provider will not agree to mount the old disk as a secondary one, so am I'm downloading the entire `/backup` folder to my local machine, and when the new drive is mounted can I upload them again to the server to `/backup` and use them from there for recovery, instead of the mounted drive. Thank you for helping
    0
  • cPRex Jurassic Moderator
    4 - If you're going to keep the same nameservers you can get those configured on the machine, but remember, if the server IP is changing you'll also need to update that value at the registrar. 5 - It's probably best to restore the system files first if you have that option. That way, all the accounts will have the correct values right from the start. 6 - Everything in that /system directory is either another directory or a flat file. For example, if you wanted to restore the /etc/exim.conf file, you'd need to do the following: -unzip _etc_exim.conf.gz from inside *backup_path/system/files/ -copy that file to /etc/exim.conf on the server -restart the Exim service
    A similar process would need to be done for all the services you want to restore. If you haven't made changes to the configurations of that service, there is no need to restore the backup, so you can focus on things you know have been changed. If you aren't sure, I just wouldn't worry about the service configurations unless you find something isn't working how you expect after the accounts are restored. 7 - Yes, the WHM interface will be able to read the user accounts and allow you to restore them through the interface.
    0
  • Spidey Catalin
    4 - If you're going to keep the same nameservers you can get those configured on the machine, but remember, if the server IP is changing you'll also need to update that value at the registrar. 5 - It's probably best to restore the system files first if you have that option. That way, all the accounts will have the correct values right from the start. 6 - Everything in that /system directory is either another directory or a flat file. For example, if you wanted to restore the /etc/exim.conf file, you'd need to do the following: -unzip _etc_exim.conf.gz from inside *backup_path/system/files/ -copy that file to /etc/exim.conf on the server -restart the Exim service
    A similar process would need to be done for all the services you want to restore. If you haven't made changes to the configurations of that service, there is no need to restore the backup, so you can focus on things you know have been changed. If you aren't sure, I just wouldn't worry about the service configurations unless you find something isn't working how you expect after the accounts are restored. 7 - Yes, the WHM interface will be able to read the user accounts and allow you to restore them through the interface.

    Not sure if I should open another thread for this, but actually I just wanna add something to what it happend within these steps. Basically, everything worked fine until a moment: 1. installed a fresh WHM on a fresh OS with new drives 2. uploaded my backed up data from the previous instalation to /backup//accounts/.. and /backup//system/ via SSH 3. within the first interaction on WHM interface, I've configured only the nameservers (the same like the previous installation). At this point I had everything prepared for restoration: accounts and system files as well. 4. according to your instructions, I have copied first the system files within each coresponding folders and subfolders (/etc, /usr and /var). I was looking first within these files, and I saw that there are some files related to my accounts so this was also a sign that these files needs to be recovered. Some of the files were already existing so choose to overwrite them when I was asked. 5. the next step was to recover the accounts. indeed, all the acccounts were recognized within backup recovery, so I've selected few accounts and added them to the recover queue, then hit the recover button to start start the account recovery process. When the first account was trying to be recovered, a critical error was thrown, saying something about the database files that are already existing and a lot of code-like-error (about 60 lines - I'm sorry that I forgot to make a printscreen or copy the error) marked all with red, stating that the recovery has failed. Then, it tried to recover the next account that was in the queue, and the result was the same long error. The nest recovery account as well. After this, I've removed all the pending accounts recovery, and tried with a single account only. At this try, I remember that the error was a smaller one, but still (red) critical, and it said something (cannot execute, or something similar, I don't remember exactly I'm afraid) about this file: /var/lib/mysql/mysql.sock. In the next minutes I got also a cPanel email notification that the mysql service failed and that was the point when I realized that my entire whm installation is compromised. 6. I've started again from scratch, and installed a new OS with WHM and uploaded my data again to the server via SSH in /backup folder. 7. I skipped the the system recovery files and started to upload the accounts only. And guess what, the accounts where recovered. Indeed, most of them had warning during the recovery process (see attachment), but at least the files were recovered and the websites of the accounts were reachable. However, now I have another issue: The quota of the files is not displayed or actually updated. Most of the accounts quota is shown as 0MB, where in reality they have 1 or 2 or 10GB or data. What should I do now ? I think the best option would be to have the updated quota of the accounts. maybe there is a command to do and update it. Maybe there are also some other downsides that I've not discovered yet because I didn't recovered the system files as well. It's weird how that happened since I used the same OS version as the previous installation and it's also frustrating that the official docs (System Backups - Version 84 Documentation - cPanel Documentation) also instructs to do this kind of system recovery while it is a total failure
    0
  • cPRex Jurassic Moderator
    It sounds like there was an issue with the manual process of the configuration file portion. You have to be careful to ensure the permissions and ownership of those files match when you restore the files/directories. I'm glad the account portion of the restore worked well. Quotas are not something that are generated in real-time, so you'll likely see those working as well within the next 24 hours.
    0

Please sign in to leave a comment.