Fully explain /scripts/restorepkg

whnewbie

Member
Jan 1, 2012
12
0
51
cPanel Access Level
Root Administrator
Hi. Just wonder if anyone knows the full explanation and effects of the /scripts/restorepkg command. I have found this: /http://www.webhostinghero.ca/how-to-back-up-and-restore-accounts-via-command-line.html

But I need more information and want to fully understand what I am using:

restorepkg [--force] [--skipres] [--override] [--ip=(y|n|Custom IP)] -- [cpuser|/path/to/cpuser-file]

In particular:
In using "--force" to overwrite accounts, does it mean the original account is terminated (totally removed) and recreated again? Or it just means overwriting files (so old and new files live together)? Or just remove and recreate databases or what???

What is the use of "--override"?

Any ideas or pointers to full explanation will be highly useful. Thanks.
 

Brian

Well-Known Member
Dec 1, 2010
117
3
68
Texas
cPanel Access Level
Root Administrator
Happy to help.

--force
If there's one thing I advise, it's to never use this flag unless you've exhausted normal means of restoring the account. Even then, I'd prefer you contact cPanel support instead so we can figure out what's going on. This option essentially instructs restorepkg to disregard all logic that we put in place to prevent conflicts when an account is being restored.

If the backup you're restoring does contain actual conflicts (domains owned by other users for example), then this sets you up for a world of hurt and unexpected behavior. I see all too often where a sysadmin has forced an account to be restored that conflicts with already existing accounts onto a box.

It does not terminate the account first; it just "shoe horn" restores it on top. The intention of this feature is if you're trying to reduce downtime or are trying to keep 'new' files (like email) that otherwise don't exist in the backup you're restoring from.

But, personally, I would never use --force on my own personal box just for the peace of mind. I'd perform a clean terminate/restore of an account and rest assured that our restorepkg logic has guaranteed me that there are no conflicts.

--skipres
This stands for "Skip Reseller Privileges". Pretty self-explanatory. Using this option will ensure that reseller privileges are NOT restored (if the account had them, that is). If it's not a reseller, this argument effectively does nothing.

--override
This allows you to override the stock cPanel restorepkg code with your own custom written restorepkg logic if you've written some.
Stock Code: /usr/local/cpanel/Whostmgr/Transfers.pm

If you desire to create your own customized version, you would place it at:
Override location: /var/cpanel/lib/Whostmgr/Transfers.pm

Then, when you use "--override" it will call upon the override location code in lieu of the stock code. Note that if you don't have an override setup at that location, the "--override" argument effectively does nothing at all.

--ip=(y|n|Custom IP)
Pretty much self-explanatory.
--ip=y
^-- Allocates the next available IP in the IP Pool to the account upon restore. If none available, uses shared IP.
--ip=n
^-- The same as leaving this flag absent. The account will restore using the shared IP of the box.
--ip=123.123.123.123 (Or any other valid IP)
^-- Attempts to allocate the specified IP to the account upon restore. If not available/does not exist, uses shared IP

cpuser|/path/to/cpuser-file
Self-explanitory again.
cpuser
Will search for archive in various common locations to try and automatically identify the backup you're requesting it to restore. If it cannot find it, it will instruct you where it looked and what it was trying to find.
/path/to/cpuser-file
Simply attempts to restore using the archive that the path specifies.

----

Hope this helps!
 

mrmincho

Registered
Jan 12, 2012
2
0
51
cPanel Access Level
Root Administrator
Great post about restorepkg, appreciate the extra info. I have one related question though:

Is the --force flag used in the WHM functions that restore an account from backup that already exists on the server? I'm referring to the daily/weekly/monthly backups. I would be interested in replicating what it does through ssh.
 

brandon001

Registered
Nov 8, 2011
3
0
51
cPanel Access Level
Root Administrator
one small query

[email protected] [/home]# /scripts/restorepkg --force xxxxxxx

restorepkg [--force] [--skipres] [--override] [--ip=(y|n|Custom IP)] -- [cpuser|/path/to/cpuser-file]

To specify a dedicated IP for a restored account, the "--ip" option requires an argument of "y" for yes,
or "n" for no. Additionally, an IP argument may be specified to set the desired dedicated IP.

Security Note: It is recommended that you do not restore a package from an untrusted source.
If you choose to ignore this warning, you should use --skipres to minimize the risk.

What should be done , why this happening
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,608
77
458
cPanel Access Level
Root Administrator
You need to put -- between the arguments and the user name:

/scripts/restorepkg --force -- cpanelkenneth
 

kalehosting

Registered
Apr 17, 2012
2
0
51
cPanel Access Level
Root Administrator
/scripts/restorepkg --force --ip=y -- xxx

how is wrong that command


[email protected] [/home]# /scripts/restorepkg --force --ip=y -- xxx
restorepkg [--force] [--skipres] [--override] [--ip=(y|n|Custom IP)] -- [cpuser|/path/to/cpuser-file]

To specify a dedicated IP for a restored account, the "--ip" option requires an argument of "y" for yes,
or "n" for no. Additionally, an IP argument may be specified to set the desired dedicated IP.

Security Note: It is recommended that you do not restore a package from an untrusted source.
If you choose to ignore this warning, you should use --skipres to minimize the risk.

--------------------

and i'm tried to that


[email protected] [/home]# /scripts/restorepkg --force --ip=y --skipres -- xxx
restorepkg [--force] [--skipres] [--override] [--ip=(y|n|Custom IP)] -- [cpuser|/path/to/cpuser-file]

To specify a dedicated IP for a restored account, the "--ip" option requires an argument of "y" for yes,
or "n" for no. Additionally, an IP argument may be specified to set the desired dedicated IP.

Security Note: It is recommended that you do not restore a package from an untrusted source.
If you choose to ignore this warning, you should use --skipres to minimize the risk.
[email protected] [/home]#
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
I just used "/scripts/restorepkg --force --ip=y -- username" on my machine and it worked to restore the account.
 

cobaltool

Registered
Jul 19, 2012
2
0
1
cPanel Access Level
Root Administrator
For some reason it does not work when run from the directory / home. If the user retrieves the full backup in the / home directory and run / scripts / restorepkg in the same directory the command is not executed. You must move under the directory / and type / scripts / restorepkg -- force -- (name of account) and everything is ok.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
The command isn't executed or you receive an error message? I've never seen the command not execute. I've seen it error, though.