本文整理汇总了PHP中hmbkp_path函数的典型用法代码示例。如果您正苦于以下问题:PHP hmbkp_path函数的具体用法?PHP hmbkp_path怎么用?PHP hmbkp_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hmbkp_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBackUpDirIsExcludedWhenBackUpDirIsInRoot
public function testBackUpDirIsExcludedWhenBackUpDirIsInRoot()
{
HM\BackUpWordPress\Path::get_instance()->set_path(dirname(__FILE__) . '/test-data/tmp');
$this->assertContains($this->backup->get_root(), hmbkp_path());
$this->assertNotEmpty($this->backup->get_excludes());
$this->assertContains(trailingslashit(hmbkp_path()), $this->backup->get_excludes());
}
示例2: hmbkp_backup_complete
function hmbkp_backup_complete($backup)
{
if ($backup->errors()) {
hmbkp_cleanup();
$file = hmbkp_path() . '/.backup_errors';
if (file_exists($file)) {
unlink($file);
}
if (!($handle = @fopen($file, 'w'))) {
return;
}
fwrite($handle, json_encode($backup->errors()));
fclose($handle);
} elseif ($backup->warnings()) {
$file = hmbkp_path() . '/.backup_warnings';
if (file_exists($file)) {
unlink($file);
}
if (!($handle = @fopen($file, 'w'))) {
return;
}
fwrite($handle, json_encode($backup->warnings()));
fclose($handle);
}
}
示例3: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
* @access public
*/
public function tearDown()
{
hmbkp_rmdirtree(hmbkp_path());
delete_option('hmbkp_path');
delete_option('hmbkp_default_path');
unset($this->backup);
}
示例4: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
*/
public function tearDown()
{
hmbkp_rmdirtree(hmbkp_path());
chmod($this->backup->get_root() . '/test-data.txt', 0664);
unset($this->backup);
HM\BackUpWordPress\Path::get_instance()->reset_path();
}
示例5: testDeltaBackupWithCommands
public function testDeltaBackupWithCommands()
{
if (!$this->backup->get_zip_command_path()) {
$this->markTestSkipped('Empty zip command path');
}
if (!$this->backup->get_mysqldump_command_path()) {
$this->markTestSkipped('Empty mysqldump command path');
}
$this->backup->backup();
$this->assertEquals('zip', $this->backup->get_archive_method());
$this->assertEquals('mysqldump', $this->backup->get_mysqldump_method());
$this->assertFileExists($this->backup->get_archive_filepath());
$this->assertArchiveContains($this->backup->get_archive_filepath(), array('test-data.txt', $this->backup->get_database_dump_filename()));
$this->assertArchiveFileCount($this->backup->get_archive_filepath(), 4);
if (!copy($this->backup->get_archive_filepath(), hmbkp_path() . '/delta.zip')) {
$this->markTestSkipped('Unable to copy backup');
}
// create a new file
file_put_contents($this->backup->get_root() . '/new.file', 'test');
if (!file_exists($this->backup->get_root() . '/new.file')) {
$this->markTestSkipped('new.file couldn\'t be created');
}
$this->backup->set_archive_filename('delta.zip');
$this->backup->backup();
$this->assertFileExists($this->backup->get_archive_filepath());
$this->assertArchiveContains($this->backup->get_archive_filepath(), array('new.file', 'test-data.txt', $this->backup->get_database_dump_filename()));
$this->assertArchiveFileCount($this->backup->get_archive_filepath(), 5);
}
示例6: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
*/
public function tearDown()
{
hmbkp_rmdirtree(hmbkp_path());
unset($this->backup);
if (file_exists($this->symlink)) {
unlink($this->symlink);
}
HM\BackUpWordPress\Path::get_instance()->reset_path();
}
示例7: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
* @access public
*/
public function tearDown()
{
hmbkp_rmdirtree($this->backup->get_path());
hmbkp_rmdirtree(hmbkp_path());
delete_option('hmbkp_path');
delete_option('hmbkp_default_path');
chmod($this->backup->get_root() . '/test-data.txt', 0664);
unset($this->backup);
}
示例8: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
*/
public function tearDown()
{
if (!function_exists('symlink')) {
return;
}
hmbkp_rmdirtree(hmbkp_path());
unset($this->backup);
@unlink($this->symlink);
HM\BackUpWordPress\Path::get_instance()->reset_path();
}
示例9: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
* @access public
*/
public function tearDown()
{
hmbkp_rmdirtree($this->backup->get_path());
hmbkp_rmdirtree(hmbkp_path());
delete_option('hmbkp_path');
delete_option('hmbkp_default_path');
unset($this->backup);
if (file_exists($this->hidden)) {
unlink($this->hidden);
}
}
示例10: testRootBackupPath
/**
* What if the backup path is in root
*
*/
public function testRootBackupPath()
{
HM\BackUpWordPress\Path::get_instance()->set_path('/');
$this->backup->set_archive_filename('backup.zip');
$this->assertEquals('/', hmbkp_path());
$this->assertEquals('/backup.zip', $this->backup->get_archive_filepath());
if (!is_writable(hmbkp_path())) {
$this->markTestSkipped('Root not writable');
}
$this->backup->backup();
$this->assertFileExists($this->backup->get_archive_filepath());
}
示例11: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
* @access public
*/
public function tearDown()
{
if (!function_exists('symlink')) {
return;
}
hmbkp_rmdirtree($this->backup->get_path());
hmbkp_rmdirtree(hmbkp_path());
delete_option('hmbkp_path');
delete_option('hmbkp_default_path');
unset($this->backup);
@unlink($this->symlink);
}
示例12: hmbkp_setup_hm_backup
/**
* Setup the HM_Backup class
*
* @return null
*/
function hmbkp_setup_hm_backup()
{
$hm_backup = HM_Backup::get_instance();
$hm_backup->path = hmbkp_path();
$hm_backup->files_only = hmbkp_get_files_only();
$hm_backup->database_only = hmbkp_get_database_only();
if (defined('HMBKP_MYSQLDUMP_PATH')) {
$hm_backup->mysql_command_path = HMBKP_MYSQLDUMP_PATH;
}
if (defined('HMBKP_ZIP_PATH')) {
$hm_backup->zip_command_path = HMBKP_ZIP_PATH;
}
$hm_backup->excludes = hmbkp_valid_custom_excludes();
}
示例13: backup
/**
* 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'));
}
}
示例14: __construct
/**
* Setup the schedule object
* Loads the options from the database and populates properties
*
* @param string $id
* @throws Exception
*/
public function __construct($id)
{
// Verify the schedule id
if (!is_string($id) || !trim($id)) {
throw new Exception('Argument 1 for ' . __METHOD__ . ' must be a non empty string');
}
// Setup HM Backup
parent::__construct();
// Store id for later
$this->id = $id;
// Load the options
$this->options = array_filter((array) get_option('hmbkp_schedule_' . $this->get_id()));
// Some properties can be overridden with defines
if (defined('HMBKP_ROOT') && HMBKP_ROOT) {
$this->set_root(HMBKP_ROOT);
}
if (defined('HMBKP_PATH') && HMBKP_PATH) {
$this->set_path(HMBKP_PATH);
}
if (defined('HMBKP_EXCLUDE') && HMBKP_EXCLUDE) {
parent::set_excludes(HMBKP_EXCLUDE, true);
}
parent::set_excludes($this->default_excludes(), true);
if (defined('HMBKP_MYSQLDUMP_PATH')) {
$this->set_mysqldump_command_path(HMBKP_MYSQLDUMP_PATH);
}
if (defined('HMBKP_ZIP_PATH')) {
$this->set_zip_command_path(HMBKP_ZIP_PATH);
}
if (defined('HMBKP_ZIP_PATH') && HMBKP_ZIP_PATH === 'PclZip' && ($this->skip_zip_archive = true)) {
$this->set_zip_command_path(false);
}
if (defined('HMBKP_SCHEDULE_START_TIME') && strtotime('HMBKP_SCHEDULE_START_TIME')) {
$this->set_schedule_start_time(strtotime('HMBKP_SCHEDULE_START_TIME'));
}
// Set the path - TODO remove external function dependancy
$this->set_path(hmbkp_path());
// Set the archive filename to site name + schedule slug + date
$this->set_archive_filename(implode('-', array(sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id(), $this->get_type(), date('Y-m-d-H-i-s', current_time('timestamp')))) . '.zip');
$this->set_database_dump_filename(implode('-', array(sanitize_title(str_ireplace(array('http://', 'https://', 'www'), '', home_url())), $this->get_id(), $this->get_type(), date('Y-m-d-H-i-s', current_time('timestamp')))) . '.sql');
// Setup the schedule if it isn't set
if (!$this->is_cron_scheduled() && $this->get_reoccurrence() !== 'manually') {
$this->schedule();
}
}
示例15: tearDown
/**
* Cleanup the backup file and tmp directory
* after every test
*
*/
public function tearDown()
{
hmbkp_rmdirtree(hmbkp_path());
unset($this->backup);
HM\BackUpWordPress\Path::get_instance()->reset_path();
}