How can I restore multiple accounts from cPanel backups?

emurad

Member
Mar 3, 2011
10
0
51
Hello,

I have an incremental cPanel backup and I need to restore +20 accounts. How can I do that from shell or any easier way than going through WHM and restoring them one by one?

Thanks.
 

LinuxTechie

Well-Known Member
Jan 22, 2011
502
14
68
cPanel Access Level
Root Administrator
Hello,

To restore a full backup file, simply move the file (usually named as username.tar.gz or cpmove-username.tar.gz) to /home directory (or /usr/home, /web, /home2, /home3, /root, /usr directory if applicable). Then login to WHM (WebHost Manager), and click on Restore a Full Backup/cpmove file link under the Backup section. Enter the user name for the account to restore in the text field after “Enter the username for the account you wish to restore”. Finally click on Restore button and wait for the restoration process to complete.

From shell :

/scripts/restorepkg username
 

LinuxTechie

Well-Known Member
Jan 22, 2011
502
14
68
cPanel Access Level
Root Administrator
Hello,

You just have to the tar the user backup directory in the form .tar.gz and need to copy it to /home partition.

Below given command will help you to create the user backup directory in the format.

$ tar -zcvf user.tar.gz user
 

jamshed_11946

Member
Aug 19, 2010
5
0
51
Bhakkar
cPanel Access Level
Root Administrator
Hello,

To restore a full backup file, simply move the file (usually named as username.tar.gz or cpmove-username.tar.gz) to /home directory (or /usr/home, /web, /home2, /home3, /root, /usr directory if applicable). Then login to WHM (WebHost Manager), and click on Restore a Full Backup/cpmove file link under the Backup section. Enter the user name for the account to restore in the text field after “Enter the username for the account you wish to restore”. Finally click on Restore button and wait for the restoration process to complete.

From shell :

/scripts/restorepkg username
Sorry to bump this thread. If I have 100+ accounts then I have to enter user name every time for all users. Is there anyway to restore all accounts?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Hello :)

You can restore multiple backups by using the following option available in Web Host Manager:

"WHM >> Backup >> Restore Multiple Backups"

If you are attempting to restore incremental backups, ensure the "Incremental Backup" option is enabled via "WHM >> Backup >> Configure Backup".

Thank you.
 

jamshed_11946

Member
Aug 19, 2010
5
0
51
Bhakkar
cPanel Access Level
Root Administrator
No one is understanding me.
I did following
1) Took remote backups of 50+ accounts from other server to my server.
2) These backups were stored in a cpanel account and I moved all accounts to /home dir by using mv command
3) No I go to Main >> Backup >> Restore a Full Backup/cpmove file and there were 50 accounts that can be restored.
4) Through this method, I have to enter user name 50 times that is time consuming.
5) Now my question is this that is there any shell command so that I can restore all these accounts from /home dir at once?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Is there a reason you did not try the option Michael indicated:

WHM >> Backup >> Restore Multiple Backups

This would have allowed you to restore multiple backups rather than individually. The option you selected of "Restore a Full Backup/cpmove file" is not the same one he had noted.

As for command line, you could do the following to restore multiple backups there.

1. Create a list of all the usernames that are being restored called /root/acctlist. You could create this script by going to the old machine and doing this command:

Code:
cat /etc/trueuserdomains | cut -d: -d' ' -f2- > /root/acctlist
This will create a file on the old machine /root/acctlist that you can copy to the new machine.

2. On the new machine, you could then issue these commands after the new machine has /root/acctlist on it:

Code:
screen
for i in `cat /root/acctlist` ;do /scripts/restorepkg $i ;done
I have the command running in screen in case your SSH connection gets shut down somehow, since the screen session isn't dependent on your specific terminal working.

If you don't have screen installed onto the new machine, you can install it using:

Code:
yum install screen
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
I don't understand why SSH would time out when this is a restore option and not a transfer option. When you are restoring backups that exist on the machine, it isn't using SSH.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
I am not referring to your prior replies but to the one that was directly above my reply since we were referring to my post. As such, I was referring directly to the fact you have the backups on the machine and tried to restore them using Main >> Backup >> Restore a Full Backup/cpmove file option. I asked if you had tried the method Michael suggested for those backups you had on the machine of WHM >> Backup >> Restore Multiple Backups, which you quoted in that reply. Under that method, SSH is not used when the backups already exist on the machine.

I am trying to assist you here in your request for what to run in command line if you have backups on the machine. I am uncertain where Transfers comes into play under any of the methods I discussed in my post other than trying to copy the /root/acctlist file itself from the old server using scp. If you cannot copy that file using scp to get it onto the new machine, you can always open the file and copy the contents, then paste them into a new file on the new machine.

Please feel free to provide specific details on anything that does not work using the method I actually suggested.