The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fully explain /scripts/restorepkg

Discussion in 'Data Protection' started by whnewbie, Jan 3, 2012.

  1. whnewbie

    whnewbie Member

    Joined:
    Jan 1, 2012
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
  2. Brian

    Brian Well-Known Member

    Joined:
    Dec 1, 2010
    Messages:
    117
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    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!
     
  3. mrmincho

    mrmincho Registered

    Joined:
    Jan 12, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. brandon001

    brandon001 Registered

    Joined:
    Nov 8, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    one small query

    root@xxxxxxx [/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
     
  5. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    You need to put -- between the arguments and the user name:

    /scripts/restorepkg --force -- cpanelkenneth
     
  6. kalehosting

    kalehosting Registered

    Joined:
    Apr 17, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    /scripts/restorepkg --force --ip=y -- xxx

    how is wrong that command


    root@srv1 [/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


    root@srv1 [/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.
    root@srv1 [/home]#
     
  7. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  8. cobaltool

    cobaltool Registered

    Joined:
    Jul 19, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    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.
     
  9. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  10. septi

    septi Active Member

    Joined:
    Dec 27, 2012
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    What about if you want to restore account to a specific directory so I do not have to rearrange accounts after that?
     
Loading...

Share This Page