Support » Plugin: WebFacing™ - cPanel® Email Accounts management & Account backup » Feature Request: Cpanel Full Account Backup

  • Resolved eWallz

    (@archonic08)


    Hi, it would be great if you can add another basic & important feature for cpanel users which is running the full account backup function. Generally most cpanel user can generate full acc backup using the native cpanel backup function, but it can only be done manually once logged into the cpanel.
    With your plugin + the UAPI, the full backup process can be automated & put on schedule (via wpcron).
    Some basic option for the backup function.
    1. Run backup now button (for manual backup)
    2. Schedule run backup
    3. List all available backup copies on hosting for user to download to pc. As well as delete backup copies which no longer needed.
    4. Display simple indicator of total disk usage for backup.

    Important benefits user will get if you can add this feature:
    1. Automated the full acc backup including email, web, db etc. This can only be done with cpanel. No other backup plugin can backup emails.
    2. Backup created is fully compatible for cpanel-to-cpanel migration. All in one acc backup.

    Thanks for consideration.

Viewing 15 replies - 1 through 15 (of 26 total)
  • Plugin Author Knut Sparhell

    (@knutsp)

    Thanks for the suggestion. I have looked at it.

    I can’t find any function to do a full account backup in UAPI. There are in WHM API1 but that seems only available to cPanel system administrators.

    UAPI has functions for managing WordPress sites within the account, including backup. But this (files and db for current site) can and are performed better from PHP/WordPresss – many good backup plugins.

    This plugin is also focused on Email. I have a compaion cPanel plugin focused on disk space and resources. Or migrate that into this plugin. UAPI seems inclomplete, and older APIs are deprecated and/or no longer working.

    Maybe later, when full account backup is possible or someone can tell me how.

    Thread Starter eWallz

    (@archonic08)

    Currently i’m using make.com to trigger automated full cpanel acc backup using the following curl https://domain.com:2083/execute/Backup/fullbackup_to_homedir

    It worked by including the Header Auth like so
    curl -H’Authorization: cpanel username:APITOKEN’ ‘https://example.com:2083/execute/Module/function?parameter=value’

    I use this API docs in order to use the user level cpanel API token (not WHM API) to run the backup function. https://api.docs.cpanel.net/cpanel/tokens/

    The UAPI docs for backup module can be found here https://api.docs.cpanel.net/openapi/cpanel/operation/fullbackup_to_homedir/

    Maybe, if you not prefer to combine this feature into existing email plugin, could you maybe come up with a simple plugin for the backup function? xD

    Which cpanel companion plugin you’re referring to? is it the one with the site health? because that one was not built for generic cpanel right?

    Plugin Author Knut Sparhell

    (@knutsp)

    Thanks again. Overlooked that, but now remember I have seen it before. Blame the clumsy script-driven documetation search not working well with my Firefox.

    Thinking having backup of account may ease the migration of email accounts/settings, in may belong in this plugin. The good thing with this is that it offloads the burden of creating huge backups from WordPress, primarily request driven, to the OS/cPanel, completely in background.

    I may start working on that next week.

    I only use shell_exec, as no need to go remote to own server. But I have had plans to extend my UAPI lib to fall back to http (WP remote request, if possible, not just curl), in case shell_exec is forbidden.

    The other cPanel plugin is focused on Dashboard, resources and disk space, now only usable under cPanel. I may migrate that into this one. Both use Site Health as framework for tests and basic info.

    Thread Starter eWallz

    (@archonic08)

    I’m glad that you found it workable.
    And yes, a fall back to other methods than shell_exec is much appreciated since 80% (just my assumption after using dozens of popular web hosts) of the cpanel shared hosting out there forbid shell_exec for security purpose.
    I think this plugin can get more install without the shell_exec requirement. For me, exposing the shell_exec on a wordpress environment will triple up the chances of the website getting compromised, especially for those with little knowledge of web security.

    Plugin Author Knut Sparhell

    (@knutsp)

    Please try version 3.5-a1-9.12-@archonic08 from Advanced view – Development Version.

    Create new and List avaialble. This is alpha experimental, inclomplete. Alot missing.

    Backup list_backups won’t return anything (empty array), so I use Fileman list_files and filter it.

    Feedback very appreciated!

    Using http calls (REST) when no shell_exec will require API token to be set manually and stored as (network) option or manually entered each session. Thinking about it.

    Thread Starter eWallz

    (@archonic08)

    i’m getting this error upon activation.
    Warning: require_once(includes/BackupTable.php): failed to open stream: No such file or directory in /home/myshop/public_html/wp-content/plugins/wf-cpanel-email-accounts/index.php on line 42

    Plugin Author Knut Sparhell

    (@knutsp)

    Sorry for that. My blunder, too eager. Forgot to add the two extra files i trunk. Happended before, when new major I add all in one go.

    Added now.

    Thread Starter eWallz

    (@archonic08)

    Ok. i’ve enabled shell_exec. Got it activated. Cleared all my error logs. All the email features seems to be working ok. But when i go to the new cPanel Backup page, and click the Add New button, nothing happen…
    Some new entries were created in the wp-admin/error_log. Please check it here https://pastebin.com/auKt93Vx

    May I know what will actually happen when i clicked the Add New button?

    Plugin Author Knut Sparhell

    (@knutsp)

    There is no (success/error) message yet, and it takes a few minutes before the backup file is readable.

    Will continue the work.

    Plugin Author Knut Sparhell

    (@knutsp)

    Please check out version 3.5-a3-9.17-@archonic08 (as Development version for download)

    Now works without shell_exec, if you:

    Add to wp-config.php

    const WF_CPANEL_USER      = 'yourcpaneluser';
    const WF_CPANEL_API_TOKEN = 'yourapitoken';

    (or use define as for other constants).

    This is alpha version, for functinality and concept demo only. My work will continue, making an UI for proper token mangement (not relying on constants) and an actually working account backup managemenet.

    Thanks for all help testing and feedback. This might be great.

    Thread Starter eWallz

    (@archonic08)

    tested & works like charm! https://snipboard.io/8Clckg.jpg
    email features are working fine too without shell_exec which is great!

    please consider adding the following in your next update:
    – i think it’s better to maintain the current token handling method (on wp-config) instead of field box in wp-admin. but if you do, pls mask the token field.
    – buttons to download & delete backup files
    – for a small site, the backup file was created almost instantly, but for larger site it might takes more time or hours. so its good to at least popup a message once the ‘Add New’ button is clicked, like ‘Backup process is now starting…pls revisit this page after sometime. Bla bla..’
    – If you can add the email notification in the API request, maybe can also put message in he popup like ‘we will notify you via the admin email once backup is completed’

    future updates maybe you can consider adding backup scheduling & retention.

    Plugin Author Knut Sparhell

    (@knutsp)

    Thanks for suggestions. Scheduling will be implemented later.
    Please try version 4.0.0-b1-9.19-@archonic08
    This will be the last for you to test, before release.
    Trye cratingbackup, get email.
    Try downloading and delete.
    Please also try what happens when no shell_exec and no constants, or wrong values in cnstants.
    This will be great!

    Thread Starter eWallz

    (@archonic08)

    Hi, ok on a clean WP install, php74, Litespeed.

    When shell_exec disabled + no constant wp-config: php Error notice

    Warning: shell_exec() has been disabled for security reasons in /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/UAPI.php on line 34
    
    Fatal error: Uncaught TypeError: json_decode() expects parameter 1 to be string, null given in /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/UAPI.php:58 Stack trace: #0 /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/UAPI.php(58): json_decode(NULL) #1 /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/UAPI.php(78): WebFacing\cPanel\UAPI::result('DomainInfo', 'list_domains') #2 /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/Main.php(85): WebFacing\cPanel\UAPI::main_domain() #3 /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/index.php(55): WebFacing\cPanel\Email\Main::admin() #4 /home/jomusto/public_html/wp-admin/includes/plugin.php(2313): include_once('/home/jomusto/p...') #5 /home/jomusto/public_html/wp-admin/plugins.php(192): plugin_sandbox_scrape('wf-cpanel-email...') #6 {main} thrown in /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/UAPI.php on line 58

    When shell_exec ON + constant API in wp-config: WP Critical error

    When shell_exec OFF + constant API in wp-config: WP Critical error

    Constant used (working fine on previous version)
    define( ‘WF_CPANEL_USER’, ‘jomusto’ );
    define( ‘WF_CPANEL_API_TOKEN’, ‘3K99PSALVH0CS7YTGAC8KXVXUHFGBBNUK’ );

    Creating Backup:
    – Working fine
    – Default email notification to admin received.
    – Can download backup file from within wp-admin (without need to actually refresh as per instructed)

    Deleting Backup:
    – Throw WP Critical error within the setting area. no success.

    [20-Sep-2022 02:25:12 UTC] PHP Fatal error:  Uncaught Error: Call to a member function delete() on null in /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/BackupTable.php:279
    Stack trace:
    #0 /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/BackupTable.php(20): WebFacing\cPanel\Email\BackupTable->process_bulk_action()
    #1 /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/BackupPage.php(31): WebFacing\cPanel\Email\BackupTable->prepare_items()
    #2 /home/jomusto/public_html/wp-includes/class-wp-hook.php(307): WebFacing\cPanel\Email\BackupPage::WebFacing\cPanel\Email\{closure}('')
    #3 /home/jomusto/public_html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
    #4 /home/jomusto/public_html/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
    #5 /home/jomusto/public_html/wp-admin/admin.php(259): do_action('cpanel-email_pa...')
    #6 {main}
      thrown in /home/jomusto/public_html/wp-content/plugins/wf-cpanel-email-accounts/includes/BackupTable.php on line 279
    

    Questions & Comments
    – Is it when the backup is completed, then it’s being moved to wp-content/cpanel/ folder? If so, this will require at least 2x of the backup size on disk free space.
    – It looks like this release still require shell_exec ON + ini_set ON to be usable for my case. I prefer the one without shell_exec. Or if you can make it functional with either one being set (shell_exec or constant).
    – On this version, backup delete is not working.
    – Unable to test using only constant (without shel_exec) – Critica error.

    Thanks for your effort!

    Plugin Author Knut Sparhell

    (@knutsp)

    HTTP API and Backup was introduced in v4.0.
    const WF_CPANEL_USER = 'yourcpaneluser'; is not needed for HTTP, but respected.
    shell_exec is still the default, but a warning is emitted, urging to add
    const WF_CPANEL_API_TOKEN = 'yourapitoken';

    Thread Starter eWallz

    (@archonic08)

    Hi, tested right away using production version. Plugin cannot be activated & triggered fatal error despite using const or define API in wp-config. I think it still checking for shell_exec.
    https://snipboard.io/dHp2LF.jpg

    I commented out the shell_exec call & checks, able to activate. Then test run a backup. Backup files is ready on cpanel default homefolder within 3s (200mb size). But its not being copied over to wp-content/cpanel…and apparently got deleted in few minutes. Yet the cpanel folder still empty…

Viewing 15 replies - 1 through 15 (of 26 total)
  • You must be logged in to reply to this topic.