Viewing File: /usr/local/cpanel/base/frontend/jupiter/backup/index.html.tt

[%
USE Api2;
USE ServerRoles;
USE Services;
USE LegacyBackup;

SET errors = [];
SET CPANEL.CPVAR.dprefix = "../";
SET can_backup_db = CPANEL.feature("mysql") && Services.is_service_provided("mysql");

SET mysql_list_db_backups = [];
IF can_backup_db;
    SET mysql_list_db_backups = Api2.exec("MysqlFE", "listdbsbackup", {});
END;

SET email_list_alias_backups = [];
IF CPANEL.feature("forwarders") && ServerRoles.is_role_enabled('MailReceive');
    SET email_list_alias_backups = Api2.exec("Email", "listaliasbackups", {});
END;

SET email_list_system_filter_info = [];
IF CPANEL.feature("blockers");
    SET email_list_system_filter_info = Api2.exec("Email", "list_system_filter_info", {});
END;

IF CPANEL.ENV.CPRESELLERSESSION.defined && can_backup_db;
    SET update_privs = execute("Mysql", "update_privileges", {});
    IF update_privs.status == 0;
        errors = errors.merge(update_privs.errors);
    END;
END;

SET backup_link = LegacyBackup.get_backup_link;

SET under_quota = 0;
SET quota_info = execute( 'Quota', 'get_quota_info' );
IF quota_info.status == 0;
    errors = errors.merge(quota_info.errors);
ELSE;
    under_quota = quota_info.data.under_quota_overall;
END;
%]

[% js_code = PROCESS js_block %]

[% WRAPPER '_assets/master.html.tt'
    page_js = js_code
    app_key = 'backup'
    page_stylesheets = ["backup/index.min.css"]
    page_scripts     = [
        "libraries/handlebars/handlebars.js",
        "backup/index.js",
    ]
-%]

<div class="body-content">
    [% IF !CPANEL.feature('backup') %]
        <meta http-equiv="refresh" content="0;url=../index.html" />
    [% ELSE %]
        [% IF errors.size() > 0 %]
            [% FOREACH message IN errors %]
        <div class="alert alert-danger" role="alert">
            <span class='glyphicon glyphicon-remove-sign' aria-hidden="true"></span>
            <div class='alert-message'>
                <strong class="alert-title">
                    [% locale.maketext('Error:') %]
                </strong>
                <span class="alert-body">
                    <span id="error-[% loop.index() %]">
                        [% message.html() %]
                    </span>
                </span>
            </div>
        </div>
            [% END %]
        [% ELSE %]

        <p id="descBackupPage" class="description">
            [% locale.maketext("Download a zipped copy of your entire site or a part of your site that you can save to your computer. When you backup your website, you have an extra copy of your information in case something happens to your host. For more information, read the [output,url,_1,documentation,target,_2,id,_3].", "//go.cpanel.net/Backup", "_blank", "lnkBackupDocumentation") %]
        </p>

        <div class="section">
            <h2 id="hdrFullBackup">
                [% locale.maketext("Full Backup") %]
            </h2>
            <p id="descFullBackup" class="description">
                [% locale.maketext("A full backup creates an archive of all of your website’s files and configuration. You can use this file to move your account to another server or to keep a local copy of your files.") %]
            </p>
            <p style="margin-bottom: 20px;">
                <a class="btn btn-primary" id="btnFullBackup" href="fullbackup.html">
                    [% locale.maketext("Download a Full Account Backup") %]
                </a>
            </p>
        </div>

        <div class="section" id="backupDownload">
            [% # system backups %]

            [% # account backups %]
            [% INCLUDE backup/_backups_list.html.tt %]
        </div>

        <div class="section">
            <h2 id="hdrPartialBackups">
                [% locale.maketext("Partial Backups") %]
            </h2>

            [% IF ServerRoles.is_role_enabled('FileStorage') -%]
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <h3 id="hdrDownloadHomeDir">[% locale.maketext("Download a Home Directory Backup") %]</h3>
                        <a id="lnkHomeDirBackup" class="btn btn-primary" href="[% backup_link %]">
                            [% locale.maketext("Home Directory") %]
                        </a>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    [% IF !under_quota %]
                        <div class="alert alert-warning" id="overdiskquota" role="alert">
                            <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                            <span class="alert-message">
                                <strong class="alert-title">[% locale.maketext('Warning:') %]</strong>
                                <span class="alert-body">
                                    [% locale.maketext("Restore is disabled because you are currently exceeding your disk quota.") %]
                                </span>
                            </span>
                        </div>
                    [% END %]
                        <h3 id="hdrRestoreHomeDir">[% locale.maketext("Restore a Home Directory Backup") %]</h3>
                        <form name="restore-home-form" id="restore-home-form">
                            <div class="form-group">
                                <div id="restore-home-message-container" class="row">
                                    <div class="col-xs-12">
                                        <span id="restore-home-spinner" style="display:none">
                                           <i class="fas fa-spinner fa-spin"></i>
                                        </span>
                                        <span id="restore-home-message">
                                        </span>
                                    </div>
                                </div>
                                <div class="row" id="restore-home-fields">
                                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                        <input type="hidden" value="[% CPANEL.homedir %]" name="dir">
                                        <input type="file" id="restore-home-file" name="file1" />
                                    </div>
                                    <div id="restore-home-file_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <button [% IF !under_quota %]disabled[% END %]
                                       id="restore-home-submit-button"
                                       class="btn btn-primary"
                                       type="submit">
                                    [% locale.maketext("Upload") %]
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            [% END -%]
            [% IF can_backup_db %]
            <div class="row">
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <h3 id="hdrDownloadMysqlDb">[% locale.maketext("Download a Database Backup") %]</h3>
                    <table fixedtruncate="1" class="sortable truncate-table table table-striped" id="sqlbackuptbl">
                        <thead>
                        <tr>
                            <th id="thMysqlDb">[% locale.maketext("Databases") %]
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                            [% FOREACH hashref IN mysql_list_db_backups %]
                            <tr>
                                <td class="cell nobrd-left truncate" truncatefixed="25">
                                    <a href="[% CPANEL.ENV.cp_security_token %]/getsqlbackup/[% hashref.db.uri %].sql.gz" id="databases_[% loop.count() %]">[% hashref.db.html() %]</a>
                                </td>
                            </tr>
                            [% END %]
                        </tbody>
                    </table>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    <h3 id="hdrRestoreMysqlDb">[% locale.maketext("Restore a Database Backup") %]</h3>
                    <form name="restore-db-form" id="restore-db-form">
                        <div class="form-group">
                            <div id="restore-db-message-container" class="row">
                                <div class="col-xs-12">
                                    <span id="restore-db-spinner" style="display:none">
                                      <i class="fas fa-spinner fa-spin"></i>
                                    </span>
                                    <span id="restore-db-message">
                                    </span>
                                </div>
                            </div>
                            <div class="row" id="restore-db-fields">
                                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                    <input type="file" id="restore-db-file" />
                                </div>
                                <div id="restore-db-file_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <button [% IF !under_quota %]disabled[% END %]
                                    id="restore-db-submit-button"
                                    class="btn btn-primary"
                                    type="submit">
                                [% locale.maketext("Upload") %]
                            </button>
                        </div>
                    </form>
                </div>
            </div>
            [% END %]

            [% IF ServerRoles.is_role_enabled('MailReceive') -%]
                [% IF CPANEL.feature("forwarders") %]
                <div class="section">
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <h3 id="hdrDownloadEmailFwdrs">[% locale.maketext("Download Email Forwarders") %]</h3>
                        <table fixedtruncate="1" class="sortable table table-striped" id="aliastbl">
                            <tr>
                                <th id="thEmailFwdrs">
                                    [% locale.maketext("Forwarders") %]
                                </th>
                            </tr>
                            <tbody>
                            [% FOREACH hashref IN email_list_alias_backups %]
                            <tr>
                                <td class="cell nobrd-left truncate" truncatefixed="25">
                                    <a href="[% CPANEL.ENV.cp_security_token %]/getaliasbackup/aliases-[% hashref.domain | url %].gz" id="forwarders_[% loop.count() %]">[%- hashref.domain.html() -%]</a>
                                </td>
                            </tr>
                            [% END %]
                            </tbody>
                        </table>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <h3 id="hdrRestoreEmailFwrds">[% locale.maketext("Restore Email Forwarders") %]</h3>
                        <form name="restore-forwarder-form" id="restore-forwarder-form">
                            <div class="form-group">
                                <div id="restore-forwarder-message-container" class="row">
                                    <div class="col-xs-12">
                                        <span id="restore-forwarder-spinner" style="display:none">
                                          <i class="fas fa-spinner fa-spin"></i>
                                        </span>
                                        <span id="restore-forwarder-message">
                                        </span>
                                    </div>
                                </div>
                                <div class="row" id="restore-forwarder-fields">
                                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                        <input type="hidden" value="[% CPANEL.homedir %]" name="dir" />
                                        <input type="file" name="file4" id="restore-forwarder-file" />
                                    </div>
                                    <div id="restore-forwarder-file_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <button [% IF !under_quota %]disabled[% END %]
                                        id="restore-forwarder-submit-button"
                                        type="submit"
                                        class="btn btn-primary">
                                    [% locale.maketext("Upload") %]
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
                </div>
                [% END %]

                [% IF CPANEL.feature("blockers") %]
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <h3 id="hdrDownloadEmailFilters">[% locale.maketext("Download Email Filters") %]</h3>
                        <table fixedtruncate="1" class="sortable table table-striped" id="filtertbl">
                            <thead>
                                <tr>
                                    <th id="thSysFilterInfo">
                                        [% locale.maketext("System Filter Info") %]
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                [% FOREACH hashref IN email_list_system_filter_info %]
                                <tr>
                                    <td class="cell nobrd-left truncate" truncatefixed="25">
                                        <a href="[% CPANEL.ENV.cp_security_token %]/getfilterbackup/[% hashref.filter_info | url %]" id="systemFilterInfo_[% loop.count() %]">[% hashref.filter_info.html() %]</a>
                                    </td>
                                </tr>
                                [% END %]
                            </tbody>
                        </table>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <h3 id="hdrRestoreEmailFilters">[% locale.maketext("Restore Email Filters") %]</h3>
                        <form name="restore-filter-form" id="restore-filter-form">
                            <div class="form-group">
                                <div id="restore-filter-message-container" class="row">
                                    <div class="col-xs-12">
                                        <span id="restore-filter-spinner" style="display:none">
                                          <i class="fas fa-spinner fa-spin"></i>
                                        </span>
                                        <span id="restore-filter-message">
                                        </span>
                                    </div>
                                </div>
                                <div class="row" id="restore-filter-fields">
                                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                        <input type="hidden" value="[% CPANEL.homedir %]" name="dir" />
                                        <input type="file" name="file3" id="restore-filter-file" />
                                    </div>
                                    <div id="restore-filter-file_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <button [% IF !under_quota %]disabled[% END %]
                                        id="restore-filter-submit-button"
                                        type="submit"
                                        class="btn btn-primary">
                                    [% locale.maketext("Upload") %]
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            [% END %]
            [% END %]
        </div>
        [% END %]
    [% END %]
</div>

<script type="text/x-handlebars-template" id="success-template">
    <div id="{{id}}" class="alert alert-success" role="alert">
        <button id="{{id}}-close" type="button"
            class="close" aria-label="[% locale.maketext('Close') %]">
            <span aria-hidden="true">&times;</span>
        </button>
        <span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
        <div class="alert-message">
            <strong class="alert-title">[% locale.maketext('Success:') %]</strong>
            <span class="alert-body"><span id="{{id}}-message">{{message}}</span></span>
        </div>
    </div>
</script>

<script type="text/x-handlebars-template" id="error-template">
    <div id="{{id}}" class="alert alert-danger" role="alert">
        <button id="{{id}}-close" type="button"
            class="close" aria-label="[% locale.maketext('Close') %]">
            <span aria-hidden="true">&times;</span>
        </button>
        <span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span>
        <div class="alert-message">
            <strong class="alert-title">[% locale.maketext('Error:') %]</strong>
            <span class="alert-body"><span id="{{id}}-message">{{message}}</span></span>
            {{#if rest.length}}
            <p class="alert-more">
                <b>[% locale.maketext('Additional Information:') %]</b>
                <ul class="people_list">
                  {{#each rest}}
                  <li>{{this}}</li>
                  {{/each}}
                </ul>
            </p>
            {{/if}}
        </div>
    </div>
</script>

[% BLOCK js_block %]
<script type="text/javascript">
    [%
    SET polyfills = [
        theme_magic_url('libraries/promise/bluebird.core.min.js'),
        theme_magic_url('libraries/fetch/fetch.umd.min.js'),
    ];
    %]

    if (!PAGE) {
        PAGE = {};
    }
    PAGE.validationTitle = [% locale.maketext("Backups").json() %];
    PAGE.missingFile     = [% locale.maketext("You must select a file to restore.").json() %];

    PAGE.restoringDb         = [% locale.maketext('Restoring database …').json() %];
    PAGE.restoringHome       = [% locale.maketext('Restoring files …').json() %];
    PAGE.restoringFilters    = [% locale.maketext('Restoring email filters …').json() %];
    PAGE.restoringForwarders = [% locale.maketext('Restoring email forwarders …').json() %];

    PAGE.session         = [% CPANEL.ENV.cp_security_token.json() %];
    PAGE.polyfills       = [% polyfills.json() %];
</script>
[% END #js_block %]

[% END #wrapper -%]
Back to Directory File Manager