How to do complete restore from .tar.gz file?

SuperBaby

Well-Known Member
Nov 27, 2003
345
0
166
Thailand
cPanel Access Level
Website Owner
Twitter
I have an old backup file (xxx.tar.gz) for the domain abc.com in a remote server. This backup file was created by the WHM daily/monthly backup. This account has been terminated. How do I do a complete restore including webpages, MySQL, chmod values etc? The old username and domain name will be used?

Do I simply do a decompression OR do I create a new cPanel account and restore from there? In either method, how exactly?

Thanks.
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,544
12
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Twitter
I have an old backup file (xxx.tar.gz) for the domain abc.com in a remote server. This backup file was created by the WHM daily/monthly backup. This account has been terminated. How do I do a complete restore including webpages, MySQL, chmod values etc? The old username and domain name will be used?

Do I simply do a decompression OR do I create a new cPanel account and restore from there? In either method, how exactly?
A full account backup may be restored and at the same time the account can be created; this may be performed using the following script via root SSH access; running the script without any CLI switches or options will show help and usage information:
Code:
# /scripts/restorepkg
To restore a specific backup archive, simply enter the same command followed by the location to the full cPanel account backup archive as seen in the following example (where "/path/to/filename.tar.gz" should be replaced by the full file system path to the backup archive):
Code:
# /scripts/restorepkg /path/to/filename.tar.gz
The same restore task may also be accomplished using WHM via the following menu path:
WHM: Main >> Backup >> Restore a Full Backup/cpmove file
Documentation: Restore a Full Backup/cpmove File
 

impload

Member
Nov 2, 2009
16
0
51
Hi this is a great question. I wanted to add onto it.
If we have a cpanel already and want to restore a daily/weekly backup for it, do we need to delete that account first and then do the restore?
 

InstaCarma_Tech

Well-Known Member
Apr 22, 2009
227
1
68
I have an old backup file (xxx.tar.gz) for the domain abc.com in a remote server. This backup file was created by the WHM daily/monthly backup. This account has been terminated. How do I do a complete restore including webpages, MySQL, chmod values etc? The old username and domain name will be used?

Do I simply do a decompression OR do I create a new cPanel account and restore from there? In either method, how exactly?

Thanks.
If the account is going to be on another server then rsync the backup file to that server and move it to the /home directory.
If it is on the same server, then move the file to the /home directory.

Assuming that the tar.gz file is now available in the /home directory on the server where it will be restored, run the following command as root :
Code:
 /scripts/restorepkg username --force
Replace username with the actual username(old account)

This will automatically create the account and restore all your webfiles, databases,emails etc.

If you want to modify the username then once the restoration is complete, do the following :

Code:
 vi /var/cpanel/users/username
Change the USER here and run :

Code:
 /scripts/updateuserdomains
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,544
12
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Twitter
Forcefully restoring a full account backup and changing an account username

... Assuming that the tar.gz file is now available in the /home directory on the server where it will be restored, run the following command as root:
Code:
/scripts/restorepkg username --force
Replace username with the actual username(old account). This will automatically create the account and restore all your webfiles, databases, emails etc.
Note: The CLI switch "--force" (for the script "restorepkg") is only necessary if needing to forcefully overwrite an existing account that is already setup or in-place (e.g., with the same username and primary domain as what's in the backup).

If you want to modify the username then once the restoration is complete, do the following:
Code:
vi /var/cpanel/users/username
Change the USER here and run:
Code:
/scripts/updateuserdomains
Cautionary Warning: The two-step process shown above (quoted in "CODE" blocks) is not a safe method to change an account username. There is more that must be done including, but not limited to, tasks such as renaming databases and database users, and updating cPanel userdata and related cPanel configuration files.

To properly change an account username and related cPanel configuration files for the account the following feature should be utilized from WHM, via either "root" access or via reseller access if granted sufficient privileges by root:

Menu path, WHM: Main >> Account Functions >> Modify an Account
Documentation: ModifyanAccount < AllDocumentation/WHMDocs < TWiki