if ( empty(get_included_files()) ) die("Direct access forbidden");
$is_db_section = ($conf_key != 'homedir' ? true : false);
<div class="panel panel-default"> <!-- restore tab <?= $section ?> section -->
<div class="panel-heading">
<div class="col-sm-3"> <!-- backup type col -->
data-parent="#restore_accordion"
href="#restore_<?= $conf_key ?>_collapse">
<span class="arw">►</span> <?= $section ?>
<div id="restore_<?= $conf_key ?>_collapse" class="panel-collapse collapse">
<p><strong>Restore Options</strong></p>
<?php if (array_key_exists($conf_key, $conf['completed']) && $conf['completed'][$conf_key]): ?>
<div class="form-group row">
<?php if ($conf['show_geo']): ?>
<label class="col-sm-2 col-form-label text-right pad-top-6" for="restore_date_<?= $conf_key ?>">From Cluster & Date</label>
<label class="col-sm-2 col-form-label text-right pad-top-6" for="restore_date_<?= $conf_key ?>">Restore From Date</label>
<?php if ($is_db_section): ?>
<select id="restore_date_<?= $conf_key ?>" class="restore-date-select form-control restore_db_date" data-baktype="<?= $conf_key ?>">
<select id="restore_date_<?= $conf_key ?>" class="restore-date-select form-control" data-baktype="<?= $conf_key ?>">
<?php if ($is_db_section): // for databases, populate the date dropdown with data-dbnames in <options> ?>
<?php foreach($conf['completed'][$conf_key] as $snap): ?>
<option class="fix-opt-locale-stamp" data-geo="<?= $snap['geo'] ?>" data-snap="<?= $snap['snap'] ?>" value="<?= $snap['geo'] ?>:<?= $snap['time'] ?>" data-dbsnaps="<?php echo_json_attrib($snap['dbs']); ?>">
<?= date_select_label($conf, $snap['geo'], $snap['time']) ?>
<?php else: // for homedirs, just add the date in <options> ?>
<?php foreach($conf['completed'][$conf_key] as $snap): ?>
<option class="fix-opt-locale-stamp" data-geo="<?= $snap['geo'] ?>" data-snap="<?= $snap['snap'] ?>" data-stamp="<?= $snap['time'] ?>" value="<?= $snap['geo'] ?>:<?= $snap['snap'] ?>">
<?= date_select_label($conf, $snap['geo'], $snap['time']) ?>
<?php if ($conf['show_geo']): ?>
<div class="col-sm-7 text-right">
Selected cluster is in <span id="geo-dest-<?= $conf_key ?>"></span>
<?php if ($is_db_section): // for databases, they also get a select for the database to restore ?>
<div class="form-group row"> <!-- select database -->
<label class="col-sm-2 col-form-label text-right pad-top-6" for="restore_dbname_<?= $conf_key ?>">Database</label>
class="form-control restore_dbname_select" data-no-db="#no_db_<?= $conf_key ?>"
id="restore_dbname_<?= $conf_key ?>"
<option value="">select</option>
<div class="col-sm-3 alert alert-danger no-db-alert" id="no_db_<?= $conf_key ?>">
<i class="glyphicon glyphicon-exclamation-sign"></i> <p>No database selected.</p>
<?php else: // homedirs get a jquery widget instead ?>
<?php browser_widget('homedir_filebrowser', $conf['home_path'], 'enable_home_restore', 'browse', true, []); ?>
<?php if ($is_db_section): // for databases, show a dump path field ?>
<div class="form-group row"> <!-- enter dump path -->
<label class="col-sm-2 col-form-label text-right pad-top-6" for="dump_path_<?= $conf_key ?>">Dump Path</label>
<div class="input-group">
<span class="input-group-addon"><?= $conf['home_path'] ?>/</span>
type="text" value="restored" class="form-control path-check"
id="dump_path_<?= $conf_key ?>" data-check-error="#path_error_<?= $conf_key ?>"
<div class="col-sm-4 alert alert-danger path-error" id="path_error_<?= $conf_key ?>">
<i class="glyphicon glyphicon-exclamation-sign"></i> <p>This folder cannot be accessed.</p>
<div class="form-group row"> <!-- select how to restore -->
<div class="col-sm-2 text-right">
<label class="col-form-label pad-top-6">Restore Method</label>
<?php if ($is_db_section): // for databases, they have 3 options on how to restore ?>
type="radio" checked="checked" value="target" name="restore_method_<?= $conf_key ?>"
>Dump backup to path above</label>
<input type="radio" value="dump_import" name="restore_method_<?= $conf_key ?>">
Dump current database to path above and overwrite current database with the backup
type="radio" value="import" name="restore_method_<?= $conf_key ?>">
Overwrite current database without dumping first <em>(not recommended)</em>
<?php else: // for homedirs, they have 2 options on how to restore, and a path that hides when unchecked ?>
<input type="radio" value="merge" checked="checked" name="restore_method_<?= $conf_key ?>">
Restore to the original path: this replaces the files that are different and keeps files not found in the backup
type="radio" value="target" name="restore_method_<?= $conf_key ?>"
>Restore to a different folder</label>
<div class="input-group" id="homedir_restore_path">
<span class="input-group-addon"><?= $conf['home_path'] ?>/</span>
<input type="text" value="restored" class="form-control path-check"
id="dump_path_<?= $conf_key ?>" data-check-error="#path_error_<?= $conf_key ?>" />
<div class="col-sm-3 alert alert-danger path-error" id="path_error_<?= $conf_key ?>">
<i class="glyphicon glyphicon-exclamation-sign"></i> <p>This folder cannot be accessed.</p>
</div> <!-- end col-sm-10 -->
<div class="col-sm-2 text-right">
<label>Email to notify on completion (optional)</label>
<input id="<?= $conf_key ?>-restore-email" class="form-control validate-email" type="email" data-err="#<?= $conf_key ?>-invalid-email" />
<div class="col-sm-4 alert alert-danger error-msg" id="<?= $conf_key ?>-invalid-email">
<i class="glyphicon glyphicon-exclamation-sign"></i> <p>Invalid email address</p>
<div class="col-sm-2"></div>
<div class="col-sm-10 restore_alert" id="restore_alert_<?= $conf_key ?>"> <!-- alert div -->
<p>Clicking Restore will queue the restoration immediately, and restoring a backup is irreversible.</p>
<p>If restoring a website which relies on a database such as a WordPress website, you may need to restore both website files and SQL data.</p>
<p class="restore_alert_msg hidden" id="restore_alert_msg_<?= $conf_key ?>">Are you sure you want to proceed with the restore?</p>
<div class="col-sm-12 row restore-alert-btns">
<div class="col-sm-2 btn-restore-col">
<button id="restore-btn-<?= $conf_key ?>" onclick="do_restore('<?= $conf_key ?>', this);" class="btn btn-primary btn-block btn-restore">Restore</button>
<span class="cancel-link"><a onclick="cancel_restore_form(this);" href="#">Cancel</a></span>
<?php error_box("{$conf_key}-restore-msg"); ?>
<p>No backups available to restore</p>
</div> <!-- end panel-body -->
</div> <!-- end collapse -->
</div> <!-- end panel -->