/**
  * Make sure setting a custom path + database dump filename correctly sets the database dump filepath
  *
  */
 public function testCustomDatabaseDumpPath()
 {
     HM\BackUpWordPress\Path::get_instance()->set_path(WP_CONTENT_DIR . '/custom');
     $this->backup->set_database_dump_filename('dump.sql');
     $this->assertEquals(HM\BackUpWordPress\Backup::conform_dir(WP_CONTENT_DIR . '/custom/dump.sql'), $this->backup->get_database_dump_filepath());
     $this->backup->dump_database();
     $this->assertFileExists($this->backup->get_database_dump_filepath());
 }
 /**
  * Perform a Backup.
  *
  * ## OPTIONS
  *
  * [--files_only]
  * : Backup files only, default to off
  *
  * [--database_only]
  * : Backup database only, defaults to off
  *
  * [--destination]
  * : dir that the backup should be save in, defaults to your existing backups directory
  *
  * [--root]
  * : dir that should be backed up, defaults to site root.
  *
  * [--zip_command_path]
  * : path to your zip binary, standard locations are automatically used
  *
  * [--mysqldump_command_path]
  * : path to your mysqldump binary, standard locations are automatically used
  *
  * [--archive_filename]
  * : filename for the resulting zip file
  *
  * [--excludes]
  * : list of paths you'd like to exclude
  *
  * ## Usage
  *
  *     wp backupwordpress backup [--files_only] [--database_only] [--path<dir>] [--root<dir>] [--zip_command_path=<path>] [--mysqldump_command_path=<path>]
  *
  * @todo errors should be bubbled from Backup, Scheduled_Backup and the like instead of being repeated.
  */
 public function backup($args, $assoc_args)
 {
     add_action('hmbkp_mysqldump_started', function () {
         WP_CLI::line(__('Backup: Dumping database...', 'backupwordpress'));
     });
     add_action('hmbkp_archive_started', function () {
         WP_CLI::line(__('Backup: Zipping everything up...', 'backupwordpress'));
     });
     $hm_backup = new HM\BackUpWordPress\Backup();
     if (!empty($assoc_args['destination'])) {
         Path::get_instance()->set_path($assoc_args['destination']);
     }
     HM\BackUpWordPress\Path::get_instance()->cleanup();
     if (!empty($assoc_args['root'])) {
         $hm_backup->set_root($assoc_args['root']);
     }
     if (!is_dir(hmbkp_path())) {
         WP_CLI::error(__('Invalid backup path', 'backupwordpress'));
         return false;
     }
     if (!is_dir($hm_backup->get_root()) || !is_readable($hm_backup->get_root())) {
         WP_CLI::error(__('Invalid root path', 'backupwordpress'));
         return false;
     }
     if (isset($assoc_args['archive_filename'])) {
         $hm_backup->set_archive_filename($assoc_args['archive_filename']);
     }
     if (!empty($assoc_args['files_only'])) {
         $hm_backup->set_type('file');
     }
     if (!empty($assoc_args['database_only'])) {
         $hm_backup->set_type('database');
     }
     if (isset($assoc_args['mysqldump_command_path'])) {
         $hm_backup->set_mysqldump_command_path($assoc_args['mysqldump_command_path']);
     }
     if (isset($assoc_args['zip_command_path'])) {
         $hm_backup->set_zip_command_path($assoc_args['zip_command_path']);
     }
     if (!empty($assoc_args['excludes'])) {
         $hm_backup->set_excludes($assoc_args['excludes']);
     }
     $hm_backup->backup();
     if (file_exists($hm_backup->get_archive_filepath())) {
         WP_CLI::success(__('Backup Complete: ', 'backupwordpress') . $hm_backup->get_archive_filepath());
     } else {
         WP_CLI::error(__('Backup Failed', 'backupwordpress'));
     }
 }
 /**
  * Assert that a zip archive contains the array
  * of filenames
  *
  * @param string path to zip file
  * @param array of filenames to check for
  * @return null
  */
 function assertArchiveContains($zip_file, $filepaths, $root = ABSPATH)
 {
     $extracted = $this->pclzip_extract_as_string($zip_file);
     $files = array();
     foreach ($filepaths as $filepath) {
         $filenames[] = str_ireplace(trailingslashit($root), '', HM\BackUpWordPress\Backup::conform_dir((string) $filepath));
     }
     foreach ($extracted as $fileInfo) {
         $files[] = untrailingslashit($fileInfo['filename']);
     }
     foreach ($filenames as $filename) {
         $this->assertContains($filename, $files);
     }
 }
Ejemplo n.º 4
0
/**
 * Send the download file to the browser and then redirect back to the backups page
 */
function hmbkp_request_download_backup()
{
    check_admin_referer('hmbkp_download_backup', 'hmbkp_download_backup_nonce');
    if (!file_exists(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])))) {
        return;
    }
    $url = str_replace(HM\BackUpWordPress\Backup::conform_dir(HM\BackUpWordPress\Backup::get_home_path()), home_url(), trailingslashit(dirname(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive']))))) . urlencode(pathinfo(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])), PATHINFO_BASENAME));
    global $is_apache;
    if ($is_apache) {
        HM\BackUpWordPress\Path::get_instance()->protect_path('reset');
        $url = add_query_arg('key', HMBKP_SECURE_KEY, $url);
    }
    wp_safe_redirect($url, 303);
    die;
}
Ejemplo n.º 5
0
function hmbkp_set_server_config_notices()
{
    $notices = HM\BackUpWordPress\Notices::get_instance();
    $messages = array();
    if (!HM\BackUpWordPress\Backup::is_shell_exec_available()) {
        $php_user = '******';
        $php_group = '<PHP GROUP>';
    } else {
        $php_user = shell_exec('whoami');
        $groups = explode(' ', shell_exec('groups'));
        $php_group = reset($groups);
    }
    if (!is_dir(hmbkp_path())) {
        $messages[] = sprintf(__('The backups directory can\'t be created because your %1$s directory isn\'t writable, run %2$s or %3$s or create the folder yourself.', 'backupwordpress'), '<code>' . esc_html(dirname(hmbkp_path())) . '</code>', '<code>chown ' . esc_html($php_user) . ':' . esc_html($php_group) . ' ' . esc_html(dirname(hmbkp_path())) . '</code>', '<code>chmod 777 ' . esc_html(dirname(hmbkp_path())) . '</code>');
    }
    if (is_dir(hmbkp_path()) && !wp_is_writable(hmbkp_path())) {
        $messages[] = sprintf(__('Your backups directory isn\'t writable, run %1$s or %2$s or set the permissions yourself.', 'backupwordpress'), '<code>chown -R ' . esc_html($php_user) . ':' . esc_html($php_group) . ' ' . esc_html(hmbkp_path()) . '</code>', '<code>chmod -R 777 ' . esc_html(hmbkp_path()) . '</code>');
    }
    if (HM\BackUpWordPress\Backup::is_safe_mode_active()) {
        $messages[] = sprintf(__('%1$s is running in %2$s, please contact your host and ask them to disable it. BackUpWordPress may not work correctly whilst %3$s is on.', 'backupwordpress'), '<code>PHP</code>', sprintf('<a href="%1$s">%2$s</a>', __('http://php.net/manual/en/features.safe-mode.php', 'backupwordpress'), __('Safe Mode', 'backupwordpress')), '<code>' . __('Safe Mode', 'backupwordpress') . '</code>');
    }
    if (defined('HMBKP_PATH') && HMBKP_PATH) {
        // Suppress open_basedir warning https://bugs.php.net/bug.php?id=53041
        if (!@file_exists(HMBKP_PATH)) {
            $messages[] = sprintf(__('Your custom path does not exist', 'backupwordpress'));
        } elseif (hmbkp_is_restricted_custom_path()) {
            $messages[] = sprintf(__('Your custom path is unreachable due to a restriction set in your PHP configuration (open_basedir)', 'backupwordpress'));
        } else {
            if (!@is_dir(HMBKP_PATH)) {
                $messages[] = sprintf(__('Your custom backups directory %1$s doesn\'t exist and can\'t be created, your backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>');
            }
            if (@is_dir(HMBKP_PATH) && !wp_is_writable(HMBKP_PATH)) {
                $messages[] = sprintf(__('Your custom backups directory %1$s isn\'t writable, new backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>');
            }
        }
    }
    $test_backup = new HM\BackUpWordPress\Backup();
    if (!is_readable($test_backup->get_root())) {
        $messages[] = sprintf(__('Your site root path %s isn\'t readable.', 'backupwordpress'), '<code>' . $test_backup->get_root() . '</code>');
    }
    if (count($messages) > 0) {
        $notices->set_notices('server_config', $messages, false);
    }
}
Ejemplo n.º 6
0
			<td>

				<?php 
if (defined('HMBKP_ROOT')) {
    ?>
					<p><?php 
    printf(__('You\'ve set it to: %s', 'backupwordpress'), '<code>' . esc_html(HMBKP_ROOT) . '</code>');
    ?>
</p>
				<?php 
}
?>

				<p><?php 
printf(__('The root directory that is backed up. Defaults to %s.', 'backupwordpress'), '<code>' . HM\BackUpWordPress\Backup::get_home_path() . '</code>');
?>
 <?php 
_e('e.g.', 'backupwordpress');
?>
 <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p>

			</td>

		</tr>

		<tr<?php 
if (defined('HMBKP_SCHEDULE_TIME') && HMBKP_SCHEDULE_TIME !== '11pm') {
    ?>
 class="hmbkp_active"<?php 
}
Ejemplo n.º 7
0
				</td>

				<td></td>

			</tr>

			</thead>

			<tbody>

			<?php 
    foreach ($files as $size => $file) {
        $is_excluded = $is_unreadable = false;
        // Check if the file is excluded
        if ($exclude_string && preg_match('(' . $exclude_string . ')', str_ireplace(trailingslashit($schedule->backup->get_root()), '', HM\BackUpWordPress\Backup::conform_dir($file->getPathname())))) {
            $is_excluded = true;
        }
        // Skip unreadable files
        if (!@realpath($file->getPathname()) || !$file->isReadable()) {
            $is_unreadable = true;
        }
        ?>

				<tr>

					<td>

						<?php 
        if ($is_unreadable) {
            ?>
 public function testMixedSlashes()
 {
     $this->assertEquals(HM\BackUpWordPress\Backup::conform_dir('\\/one\\//\\two\\/\\three'), $this->dir);
 }
 /**
  * Test that backups are correctly merged from multiple existing backup paths
  */
 public function testMergeExistingPath()
 {
     $paths = $this->generate_additional_paths();
     // Do a single database backup in each path
     foreach ($paths as $path) {
         $this->path->set_path($path);
         $backup = new HM\BackUpWordPress\Backup();
         $backup->set_type('database');
         // We want to avoid name clashes
         $backup->set_archive_filename(microtime() . '.zip');
         $backup->backup();
         $this->assertFileExists($backup->get_archive_filepath());
         $backups[] = $backup->get_archive_filename();
     }
     $this->path->merge_existing_paths();
     foreach ($backups as $backup) {
         $this->assertFileExists($this->path->get_path() . '/' . $backup);
     }
 }
    function get_excluded($browse_dir = null)
    {
        $schedule_id = $this->check_schedule();
        $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field(urldecode($schedule_id)));
        ob_start();
        ?>
    <div class="hmbkp-exclude-settings">

	<?php 
        if ($schedule->get_excludes()) {
            ?>

		<h3>
			<?php 
            _e('Currently Excluded', 'backupwordpress');
            ?>
		</h3>

		<p><?php 
            _e('We automatically detect and ignore common <abbr title="Version Control Systems">VCS</abbr> folders and other backup plugin folders.', 'backupwordpress');
            ?>
</p>

		<table class="widefat">

			<tbody>

			<?php 
            foreach (array_diff($schedule->get_excludes(), $schedule->backup->default_excludes()) as $key => $exclude) {
                $exclude_path = new SplFileInfo(trailingslashit($schedule->backup->get_root()) . ltrim(str_ireplace($schedule->backup->get_root(), '', $exclude), '/'));
                ?>

				<tr>

					<th scope="row">

						<?php 
                if ($exclude_path->isFile()) {
                    ?>

							<div class="dashicons dashicons-media-default"></div>

						<?php 
                } elseif ($exclude_path->isDir()) {
                    ?>

							<div class="dashicons dashicons-portfolio"></div>

						<?php 
                }
                ?>

					</th>

					<td>
						<code><?php 
                echo esc_html(str_ireplace($schedule->backup->get_root(), '', $exclude));
                ?>
</code>

					</td>

					<td>

						<?php 
                if (in_array($exclude, $schedule->backup->default_excludes()) || hmbkp_path() === untrailingslashit($exclude)) {
                    ?>

							<?php 
                    _e('Default rule', 'backupwordpress');
                    ?>

						<?php 
                } elseif (defined('HMBKP_EXCLUDE') && false !== strpos(HMBKP_EXCLUDE, $exclude)) {
                    ?>

							<?php 
                    _e('Defined in wp-config.php', 'backupwordpress');
                    ?>

						<?php 
                } else {
                    ?>

							<a href="#" onclick="event.preventDefault(); mainwp_backupwp_remove_exclude_rule('<?php 
                    echo $exclude;
                    ?>
', this);"  class="delete-action"><?php 
                    _e('Stop excluding', 'backupwordpress');
                    ?>
</a>

						<?php 
                }
                ?>

					</td>

				</tr>

			<?php 
            }
            ?>

			</tbody>

		</table>

	<?php 
        }
        ?>

	<h3 id="directory-listing"><?php 
        _e('Directory Listing', 'backupwordpress');
        ?>
</h3>

	<p><?php 
        _e('Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'backupwordpress');
        ?>
</p>

	<?php 
        // The directory to display
        $directory = $schedule->backup->get_root();
        if (isset($browse_dir)) {
            $untrusted_directory = urldecode($browse_dir);
            // Only allow real sub directories of the site root to be browsed
            if (false !== strpos($untrusted_directory, $schedule->backup->get_root()) && is_dir($untrusted_directory)) {
                $directory = $untrusted_directory;
            }
        }
        $exclude_string = $schedule->backup->exclude_string('regex');
        // Kick off a recursive filesize scan
        $files = $schedule->list_directory_by_total_filesize($directory);
        if ($files) {
            ?>

            <table class="widefat">
                <thead>
                <tr>
                        <th></th>
                        <th scope="col"><?php 
            _e('Name', 'backupwordpress');
            ?>
</th>
                        <th scope="col" class="column-format"><?php 
            _e('Size', 'backupwordpress');
            ?>
</th>
                        <th scope="col" class="column-format"><?php 
            _e('Permissions', 'backupwordpress');
            ?>
</th>
                        <th scope="col" class="column-format"><?php 
            _e('Type', 'backupwordpress');
            ?>
</th>
                        <th scope="col" class="column-format"><?php 
            _e('Status', 'backupwordpress');
            ?>
</th>
                </tr>

                <tr>

                        <th scope="row">
                                <div class="dashicons dashicons-admin-home"></div>
                        </th>

                        <th scope="col">

                                <?php 
            if ($schedule->backup->get_root() !== $directory) {
                // echo esc_url( remove_query_arg( 'hmbkp_directory_browse' ) );
                ?>
                                        <a href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse('', this)"><?php 
                echo esc_html($schedule->backup->get_root());
                ?>
</a>
                                        <code>/</code>

                                        <?php 
                $parents = array_filter(explode('/', str_replace(trailingslashit($schedule->backup->get_root()), '', trailingslashit(dirname($directory)))));
                foreach ($parents as $directory_basename) {
                    ?>

                                                <a href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php 
                    echo urlencode(substr($directory, 0, strpos($directory, $directory_basename)) . $directory_basename);
                    ?>
', this)" ><?php 
                    echo esc_html($directory_basename);
                    ?>
</a>
                                                <code>/</code>

                                        <?php 
                }
                ?>

                                        <?php 
                echo esc_html(basename($directory));
                ?>

                                <?php 
            } else {
                ?>

                                        <?php 
                echo esc_html($schedule->backup->get_root());
                ?>

                                <?php 
            }
            ?>

                        </th>

                        <td class="column-filesize">

                                <?php 
            if ($schedule->is_site_size_being_calculated()) {
                ?>

                                        <span class="spinner"></span>

                                <?php 
            } else {
                $root = new SplFileInfo($schedule->backup->get_root());
                $size = $schedule->filesize($root, true);
                if (false !== $size) {
                    $size = size_format($size);
                    if (!$size) {
                        $size = '0 B';
                    }
                    ?>

                                                <code>

                                                        <?php 
                    echo esc_html($size);
                    ?>

                                                        <a class="dashicons dashicons-update"
                                                           href="<?php 
                    echo wp_nonce_url(add_query_arg('hmbkp_recalculate_directory_filesize', urlencode($schedule->backup->get_root())), 'hmbkp-recalculate_directory_filesize');
                    ?>
"><span><?php 
                    _e('Refresh', 'backupwordpress');
                    ?>
</span></a>

                                                </code>


                                        <?php 
                }
                ?>

                                <?php 
            }
            ?>

                        <td>
                                <?php 
            echo esc_html(substr(sprintf('%o', fileperms($schedule->backup->get_root())), -4));
            ?>
                        </td>

                        <td>

                                <?php 
            if (is_link($schedule->backup->get_root())) {
                _e('Symlink', 'backupwordpress');
            } elseif (is_dir($schedule->backup->get_root())) {
                _e('Folder', 'backupwordpress');
            }
            ?>

                        </td>

                        <td></td>

                </tr>

                </thead>

                <tbody>

                <?php 
            foreach ($files as $size => $file) {
                $is_excluded = $is_unreadable = false;
                // Check if the file is excluded
                if ($exclude_string && preg_match('(' . $exclude_string . ')', str_ireplace(trailingslashit($schedule->backup->get_root()), '', HM\BackUpWordPress\Backup::conform_dir($file->getPathname())))) {
                    $is_excluded = true;
                }
                // Skip unreadable files
                if (!@realpath($file->getPathname()) || !$file->isReadable()) {
                    $is_unreadable = true;
                }
                ?>

                        <tr>

                                <td>

                                        <?php 
                if ($is_unreadable) {
                    ?>

                                                <div class="dashicons dashicons-dismiss"></div>

                                        <?php 
                } elseif ($file->isFile()) {
                    ?>

                                                <div class="dashicons dashicons-media-default"></div>

                                        <?php 
                } elseif ($file->isDir()) {
                    ?>

                                                <div class="dashicons dashicons-portfolio"></div>

                                        <?php 
                }
                ?>

                                </td>

                                <td>

                                        <?php 
                if ($is_unreadable) {
                    ?>

                                                <code class="strikethrough"
                                                      title="<?php 
                    echo esc_attr($file->getRealPath());
                    ?>
"><?php 
                    echo esc_html($file->getBasename());
                    ?>
</code>

                                        <?php 
                } elseif ($file->isFile()) {
                    ?>

                                                <code
                                                        title="<?php 
                    echo esc_attr($file->getRealPath());
                    ?>
"><?php 
                    echo esc_html($file->getBasename());
                    ?>
</code>

                                        <?php 
                } elseif ($file->isDir()) {
                    //echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
                    ?>
                                                <code title="<?php 
                    echo esc_attr($file->getRealPath());
                    ?>
"><a
                                                        href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php 
                    echo urlencode($file->getPathname());
                    ?>
', this)" ><?php 
                    echo esc_html($file->getBasename());
                    ?>
</a></code>

                                        <?php 
                }
                ?>

                                </td>

                                <td class="column-format column-filesize">

                                        <?php 
                if ($file->isDir() && $schedule->is_site_size_being_calculated()) {
                    ?>

                                                <span class="spinner"></span>

                                        <?php 
                } else {
                    $size = $schedule->filesize($file);
                    if (false !== $size) {
                        $size = size_format($size);
                        if (!$size) {
                            $size = '0 B';
                        }
                        ?>

                                                        <code>

                                                                <?php 
                        echo esc_html($size);
                        ?>

                                                                <?php 
                        if ($file->isDir()) {
                            ?>

                                                                        <a title="<?php 
                            _e('Recalculate the size of this directory', 'backupwordpress');
                            ?>
"
                                                                           class="dashicons dashicons-update"
                                                                           href="<?php 
                            echo wp_nonce_url(add_query_arg('hmbkp_recalculate_directory_filesize', urlencode($file->getPathname())), 'hmbkp-recalculate_directory_filesize');
                            ?>
"><span><?php 
                            _e('Refresh', 'backupwordpress');
                            ?>
</span></a>

                                                                <?php 
                        }
                        ?>

                                                        </code>


                                                <?php 
                    } else {
                        ?>

                                                        <code>--</code>

                                                <?php 
                    }
                }
                ?>

                                </td>

                                <td>
                                        <?php 
                echo esc_html(substr(sprintf('%o', $file->getPerms()), -4));
                ?>
                                </td>

                                <td>

                                        <?php 
                if ($file->isLink()) {
                    ?>

                                                <span
                                                        title="<?php 
                    echo esc_attr($file->GetRealPath());
                    ?>
"><?php 
                    _e('Symlink', 'backupwordpress');
                    ?>
</span>

                                        <?php 
                } elseif ($file->isDir()) {
                    _e('Folder', 'backupwordpress');
                } else {
                    _e('File', 'backupwordpress');
                }
                ?>

                                </td>

                                <td class="column-format">

                                        <?php 
                if ($is_unreadable) {
                    ?>

                                                <strong
                                                        title="<?php 
                    _e('Unreadable files won\'t be backed up.', 'backupwordpress');
                    ?>
"><?php 
                    _e('Unreadable', 'backupwordpress');
                    ?>
</strong>

                                        <?php 
                } elseif ($is_excluded) {
                    ?>

                                                <strong><?php 
                    _e('Excluded', 'backupwordpress');
                    ?>
</strong>

                                        <?php 
                } else {
                    $exclude_path = $file->getPathname();
                    // Excluded directories need to be trailingslashed
                    if ($file->isDir()) {
                        $exclude_path = trailingslashit($file->getPathname());
                    }
                    ?>

                                                <a href="#" onclick="event.preventDefault(); mainwp_backupwp_exclude_add_rule('<?php 
                    echo urlencode($exclude_path);
                    ?>
', this)"
                                                   class="button-secondary"><?php 
                    _e('Exclude &rarr;', 'backupwordpress');
                    ?>
</a>

                                        <?php 
                }
                ?>

                                </td>

                        </tr>

                <?php 
            }
            ?>
                </tbody>
        </table>

                <?php 
        }
        ?>

                <p class="submit">
                        <a href="#" onclick="event.preventDefault(); mainwp_backupwp_edit_exclude_done()"
                           class="button-primary"><?php 
        _e('Done', 'backupwordpress');
        ?>
</a>
                </p>

        </div>

        <?php 
        $output = ob_get_clean();
        $information['e'] = $output;
        return $information;
    }
Ejemplo n.º 11
0
function hmbkp_is_path_accessible($dir)
{
    // Path is inaccessible
    if (strpos($dir, HM\BackUpWordPress\Backup::get_home_path()) === false) {
        return false;
    }
    return true;
}
Ejemplo n.º 12
0
        break;
    case 'hmbkp_fortnightly':
        $reoccurrence = sprintf(__('biweekly on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'hmbkp_monthly':
        $reoccurrence = sprintf(__('on the %1$s of each month at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n('jS', $schedule->get_next_occurrence(false))) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'manually':
        $reoccurrence = __('manually', 'backupwordpress');
        break;
    default:
        $reoccurrence = __('manually', 'backupwordpress');
        $schedule->set_reoccurrence('manually');
}
$server = '<span title="' . esc_attr(hmbkp_path()) . '">' . __('this server', 'backupwordpress') . '</span>';
$server = '<code>' . esc_attr(str_replace(HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path())) . '</code>';
// Backup to keep
switch ($schedule->get_max_backups()) {
    case 1:
        $backup_to_keep = sprintf(__('store the most recent backup in %s', 'backupwordpress'), $server);
        break;
    case 0:
        $backup_to_keep = sprintf(__('don\'t store any backups in on this server', 'backupwordpress'), hmbkp_path());
        break;
    default:
        $backup_to_keep = sprintf(__('store the last %1$s backups in %2$s', 'backupwordpress'), esc_html($schedule->get_max_backups()), $server);
}
$email_msg = $services = '';
foreach (HM\BackUpWordPress\Services::get_services($schedule) as $file => $service) {
    if ('Email' === $service->name) {
        $email_msg = wp_kses_post($service->display());
 function testSafeModeTrue()
 {
     $this->safe_mode = true;
     $this->assertEquals($this->ini_get_mock(), true);
     $this->assertTrue(HM\BackUpWordPress\Backup::is_safe_mode_active(array($this, 'ini_get_mock')));
 }