$wpdb->flush(); } function CreateWPFullBackupZip($backupName, $zipmode, $use_wpdb = false) { $folderToBeZipped = WPCLONE_DIR_BACKUP . 'wpclone_backup'; $destinationPath = $folderToBeZipped . '/' . basename(WPCLONE_WP_CONTENT); $zipFileName = WPCLONE_DIR_BACKUP . $backupName . '.zip'; $exclude = wpa_excluded_dirs(); $dbonly = isset($_POST['dbonly']) && 'true' == $_POST['dbonly'] ? true : false; if (false === mkdir($folderToBeZipped)) { wpa_backup_error('file', sprintf(__('Unable to create the temporary backup directory,please make sure that PHP has permission to write into the <code>%s</code> directory.'), WPCLONE_DIR_BACKUP)); } if (false === $dbonly) { wpa_copy_dir(untrailingslashit(WPCLONE_WP_CONTENT), $destinationPath, $exclude); } wpa_save_prefix($folderToBeZipped); /* error handler is called from within the db backup functions */ if ($use_wpdb) { wpa_db_backup_wpdb($folderToBeZipped); } else { wpa_db_backup_direct($folderToBeZipped); } /* error haldler is called from within the wpa_zip function */ wpa_zip($zipFileName, $folderToBeZipped, $zipmode); $zipSize = filesize($zipFileName); wpa_delete_dir($folderToBeZipped);
function CreateWPFullBackupZip($backupName, $zipmode, $use_wpdb = false) { $folderToBeZipped = WPCLONE_DIR_BACKUP . 'wpclone_backup'; $htaccess = "<Files>\r\n\tOrder allow,deny\r\n\tDeny from all\r\n\tSatisfy all\r\n</Files>"; $zipFileName = WPCLONE_DIR_BACKUP . $backupName . '.zip'; $exclude = wpa_excluded_dirs(); $dbonly = isset($_POST['dbonly']) && 'true' == $_POST['dbonly'] ? true : false; $skip = 25 * 1024 * 1024; if (isset($_POST['skipfiles']) && '' !== $_POST['skipfiles']) { if (0 === $_POST['skipfiles']) { $skip = false; } else { $skip = $_POST['skipfiles'] * 1024 * 1024; } } if (false === mkdir($folderToBeZipped)) { wpa_backup_error('file', sprintf(__('Unable to create the temporary backup directory,please make sure that PHP has permission to write into the <code>%s</code> directory.'), WPCLONE_DIR_BACKUP)); } file_put_contents($folderToBeZipped . '/.htaccess', $htaccess); if ($dbonly) { wpa_wpc_log('database only backup, no files will be copied'); } if (false === $dbonly) { if ($skip) { wpa_wpc_log(sprintf('files larger than %s will be excluded from the backup', bytesToSize($skip))); } wpa_wpc_log('generating file list'); file_put_contents($folderToBeZipped . '/file.list', serialize(wpa_wpc_get_filelist(WPCLONE_WP_CONTENT, $exclude, $skip))); wpa_wpc_log('finished generating file list'); } wpa_save_prefix($folderToBeZipped); /* error handler is called from within the db backup functions */ if ($use_wpdb) { wpa_wpc_log('database backup started [wpdb]'); wpa_db_backup_wpdb($folderToBeZipped); } else { wpa_wpc_log('database backup started'); wpa_db_backup_direct($folderToBeZipped); } wpa_wpc_log('database backup finished'); /* error haldler is called from within the wpa_zip function */ wpa_zip($zipFileName, $folderToBeZipped, $zipmode); wpa_delete_dir($folderToBeZipped); if (!file_exists($zipFileName)) { wpa_backup_error('backup', 'possibly out of free disk space'); } $zipSize = filesize($zipFileName); return array($backupName, $zipSize); }