当前位置: 首页>>代码示例>>PHP>>正文


PHP backup函数代码示例

本文整理汇总了PHP中backup函数的典型用法代码示例。如果您正苦于以下问题:PHP backup函数的具体用法?PHP backup怎么用?PHP backup使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了backup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install

function install($db, $udb, $fname, $dbinfo)
{
    mysql_select_db($udb, $db);
    if (!backup($dbinfo)) {
        printf("Backup failed. Cowardly refusing to continue.<br><a href='?typ=forms'>Return</a>");
        return;
    }
    // Load the file into a variable, it gets loaded as an array
    //$mytxt = file(dirname(__FILE__) . '/' . 'sqlsetup/setupWSE' . '.sql');
    //$mytxt = file(dirname(__FILE__) . '/' . $fname . '.sql');
    $mytxt = file(dirname(__FILE__) . '/' . $fname);
    $current_statement = "";
    // Loop through the array, reassemble the statements
    foreach ($mytxt as $count => $line) {
        // Remove the -- comments
        if (substr(trim($line), 0, 2) != '#') {
            $current_statement .= "\n" . rtrim($line);
        }
        // This marks the end of an SQL statement
        if (preg_match('~;[\\s]*$~s', $line) == 1) {
            if ($_GET["opt"] != "supress") {
                printf("Executing: <b>" . $current_statement . "</b><br>");
            } else {
                printf("Executing: <b>" . htmlspecialchars($current_statement) . "</b><br>");
            }
            // Attempt to execute the statement
            if (!mysql_query($current_statement)) {
                printf("Error: " . mysql_error($db) . "<br>");
            }
            // Reset the statement to blank, to build the next one.
            $current_statement = "";
            printf("<br>");
        }
    }
    printf("Installation finished.<br><a href='?typ=forms'>Return</a>");
}
开发者ID:pietersartain,项目名称:webtools,代码行数:36,代码来源:install.php

示例2: get_dbhost

#!/usr/bin/php
<?php 
//exit;
require_once 'config.php';
echo "{$hosts}";
$host = get_dbhost($hosts);
$sag = new Sag($host, $dbport);
function input()
{
    $stdin = fopen('php://stdin', 'r');
    $resp = fgetc($stdin);
    return $resp;
}
echo " HAVE YOU set config in hosts? !!!!!\n";
echo "brand_provisioner install file -> couchdb on {$hosts} (only 1)? Y/N ";
$resp = input();
if ($resp == 'Y') {
    restore('brand_provisioner', 'DB_INSTALL/brand_provisioner/');
    restore('system_config', 'DB_INSTALL/system_config/');
}
echo "brand_provisioner restore from couchdb -> file ? Y/N ";
$resp = input();
if ($resp == 'Y') {
    backup('brand_provisioner', 'DB_INSTALL/brand_provisioner/', false);
    backup('system_config', 'DB_INSTALL/system_config/', 'crossbar.devices');
}
sleep(2);
开发者ID:urueedi,项目名称:kazoo-provision,代码行数:27,代码来源:setup.php

示例3: backup

<?php

require 'functions.php';
backup('/work/htdocs/switch-dev.adsage.tk/1', 'test1.zip');
开发者ID:zeus911,项目名称:versionSwitchTool,代码行数:4,代码来源:test.php

示例4: back_base_init

 * User: apple
 * Date: 15/10/27
 * Time: 下午11:15
 */
include 'library/init.inc.php';
back_base_init();
$template = 'backup/';
assign('subTitle', '数据备份');
$action = 'edit|add|view|delete';
$operation = 'backup';
$act = check_action($action, getGET('act'));
$act = $act == '' ? 'view' : $act;
$opera = check_action($operation, getPOST('opera'));
if ('backup' == $opera) {
    $respone = array('error' => 1, 'msg' => '');
    $file = backup();
    if ($file) {
        $response['error'] = 0;
        $response['msg'] = '备份成功<a href="' . $file . '">备份文件</a>';
        show_system_message('备份成功');
    } else {
        $response['msg'] = '系统繁忙,请稍后再试';
        show_system_message($response['msg']);
    }
    echo json_encode($response);
    exit;
}
$files = array();
$dir = dir('backup');
$pattern = '/db-backup-\\d+/';
while ($path = $dir->read()) {
开发者ID:Winsen1990,项目名称:direct-sale,代码行数:31,代码来源:backup.php

示例5: redirect

            }
        }
    }
    redirect(BASE_PATH . '/backup/?token=' . $_SESSION['token'], 1);
}
$error = true;
if (validRequest()) {
    if (isset($_SESSION['login']) && $_SESSION['permission'] == 'admin') {
        if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
            $error = false;
            $do = 'view';
            if (isset($_GET['do']) && !empty($_GET['do'])) {
                $do = trim(strtolower($_GET['do']));
            }
            switch ($do) {
                case 'view':
                    view($pdo);
                    break;
                case 'backup':
                    backup($pdo);
                    break;
                case 'restore':
                    restore($pdo);
                    break;
            }
        }
    }
}
if ($error) {
    redirect(BASE_PATH . '/index.php', 1);
}
开发者ID:parsinegar2015,项目名称:parsinegar,代码行数:31,代码来源:backup.php

示例6: date

<?php

include '../../main/connection.php';
//membuat nama file
$file = $database . '_' . date("DdMY") . '.sql';
backup($file);
$file = $back_dir . $file;
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: private');
    header('Pragma: private');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
} else {
    echo "file {$file} sudah tidak ada.";
}
function backup($nama_file, $tables = '')
{
    global $return, $tables, $back_dir, $database;
    if ($tables == '') {
        $tables = array();
        $result = @mysql_list_tables($database);
        while ($row = @mysql_fetch_row($result)) {
            $tables[] = $row[0];
开发者ID:Zame31,项目名称:SeminarProject,代码行数:31,代码来源:backup.php

示例7: _backUp

 /**
  * Updater::_backUp()
  * 
  * @return
  */
 private function _backUp()
 {
     $this->parent->parent->debug($this::name_space . ': Backing up module dir...');
     // Create the temp dir path
     $tempDir = __TEMP__ . '/' . strtolower($this->module_ns) . '.bak';
     // Now if the directory already exists, remove it
     if (file_exists($tempDir) && is_dir($tempDir)) {
         WebApp::rmDir($tempDir);
     }
     // (Re)create the temp dir
     mkdir($tempDir);
     // Now we copy the module files to the payload dir
     if (rcopy($this->module_dir, $tempDir . '/payload')) {
         // Copy the module.xml as we'll need it for restoration
         rename($tempDir . '/payload/module.xml', $tempDir . '/module.xml');
         $this->parent->parent->debug($this::name_space . ': Copied module to __TEMP__/"' . strtolower($this->module_ns) . '.bak"!');
         // If the module specified the backup flag when installed, we can now run the backup() function for it
         if ($this->backup) {
             @(include $this->module_dir . '/backup.php');
             if (is_callable('backup')) {
                 backup();
             } else {
                 $this->parent->parent->debug($this::name_space . ': Couldn\\t find backup()!');
             }
         }
         // With that done, we can move onto the next step
         return new ActionResult($this, '/admin/modules/update/', 0, 'Updating module files...', B_T_SUCCESS, array('step' => 3, 'status' => 1, 'msg' => 'Updating module files...'));
     } else {
         // if(rcopy($this->module_dir, $tempDir.'/payload'))
         // Yup, couldn't back it up
         $this->parent->parent->debug($this::name_space . ': Failed to backup module!');
     }
     // Return generic couldn't back up the module
     return new ActionResult($this, '/admin/modules/update/', 0, 'Failed to back up the module!', B_T_FAIL, array('status' => 0, 'msg' => 'Failed to back up the module!'));
 }
开发者ID:huwcbjones,项目名称:WebFramework,代码行数:40,代码来源:update.php

示例8: restore_id

function restore_id($storeid)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$storeid}.pid";
    $pid = @file_get_contents("{$pidfile}");
    if ($unix->process_exists($pid, basename(__FILE__))) {
        events("Process {$pid} already exists...aborting");
        die;
    }
    @file_put_contents($pidfile, getmypid());
    include_once dirname(__FILE__) . "/ressources/class.mysql.syslogs.inc";
    $sock = new sockets();
    $SargOutputDir = $sock->GET_INFO("SargOutputDir");
    if ($SargOutputDir == null) {
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    $sarg_bin = $unix->find_program("sarg");
    if (!is_file($sarg_bin)) {
        sarg_admin_events("Fatal, unable to locate sarg binary, aborting...", __FUNCTION__, __FILE__, __LINE__, "sarg");
        return;
    }
    $bzip2 = $unix->find_program("bzip2");
    $gunzip = $unix->find_program("gunzip");
    $TempDir = "/home/artica-extract-temp";
    @mkdir($TempDir, 0777);
    @chown($TempDir, "mysql");
    @chdir($TempDir, "mysql");
    if (!is_file("/etc/squid3/sarg.conf")) {
        buildconf();
    }
    $q = new mysql_storelogs();
    $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT filename FROM files_info WHERE storeid='{$storeid}'"));
    $filename = $ligne["filename"];
    events("Extracting infos from {$filename}");
    $EnableSyslogDB = @file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSyslogDB");
    if (!is_numeric($EnableSyslogDB)) {
        $EnableSyslogDB = 0;
    }
    if ($EnableSyslogDB == 0) {
        events("Extracting infos from {$filename} failed, SyslogDB is not enabled");
        return;
    }
    $q = new mysql_storelogs();
    $sql = "SELECT filecontent INTO DUMPFILE '{$TempDir}/{$filename}' FROM files_store WHERE ID = '{$storeid}'";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        events("Failed!!! {$q->mysql_error}", 100);
        return;
    }
    $file_extension = file_extension($filename);
    progress("Extract {$filename} extension: {$file_extension}", 5);
    $newtFile = $filename . ".log";
    if ($file_extension == "bz2") {
        $cmdline = "{$bzip2} -d \"{$TempDir}/{$filename}\" -c >\"{$TempDir}/{$newtFile}.log\" 2>&1";
        exec($cmdline, $results);
    }
    if ($file_extension == "gz") {
        $cmdline = "{$gunzip} -d \"{$TempDir}/{$filename}\" -c >\"{$TempDir}/{$newtFile}.log\" 2>&1";
    }
    if ($cmdline != null) {
        exec($cmdline, $results);
        progress("Extract done " . @implode(" ", $results), 7);
    } else {
        if (!@copy("{$TempDir}/{$filename}", "{$TempDir}/{$newtFile}.log")) {
            progress("Failed!!! Copy error", 100);
            return;
        }
    }
    @unlink("{$TempDir}/{$filename}");
    if (!is_file("{$TempDir}/{$newtFile}.log")) {
        progress("Failed!!! {$TempDir}/{$newtFile}.log error no such file", 100);
        return;
    }
    $t = time();
    sargToFile("{$TempDir}/{$newtFile}.log");
    progress("{$filename} ({$storeid}) done " . $unix->distanceOfTimeInWords($t, time()));
    backup();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:78,代码来源:exec.sarg.php

示例9: get_dbhost

#!/usr/bin/php
<?php 
require_once 'config.php';
require_once 'phplib/Sag.php';
require_once 'setup_functions.php';
require_once 'functions.php';
$host = get_dbhost($hosts);
$sag = new Sag($host);
function input()
{
    $stdin = fopen('php://stdin', 'r');
    $resp = fgetc($stdin);
    return $resp;
}
echo "HAVE YOU set config in hosts? !!!!!\n";
echo "system_config/crossbar.phone_numbers install file -> couchdb on {$hosts} (only 1)? Y/N ";
$resp = input();
if ($resp == 'Y') {
    restore('system_config', 'DB_INSTALL/system_config/', 'update');
}
echo "system_config/crossbar.phone_numbers restore from couchdb -> file ? Y/N ";
$resp = input();
if ($resp == 'Y') {
    backup('system_config', 'DB_INSTALL/system_config/', 'crossbar.phone_numbers');
}
sleep(2);
开发者ID:urueedi,项目名称:kazoo-regextern,代码行数:26,代码来源:setup.php

示例10: date

            <form action="" method="post" name="postform" >
                <div class="asd">
                    <label for="backup"><h2><b>Backup Database</b></h2></label>
                    <br>
                    <input type="submit" name="backup" value="Proses Backup" />
            </form>
    </center>

    <?php 
include "backup.php";
$database = 'Backup';
$file = $database . '_' . date("D, d-M-Y") . '_' . time() . '.sql';
//Backup database
if (isset($_POST['backup'])) {
    // Backup Semua Tabel
    backup("localhost", "root", "", "klinik", $file, "*");
    // Backup Hanya Tabel Tertentu
    //backup("localhost","user_database","pass_database","nama_database",$file,"tabel1,tabel2,tabel3");
    echo 'Backup database telah selesai <a style="cursor:pointer" href="?nama_file=' . $file . '" title="Download">Download file database</a>';
    echo "<pre>";
    echo "</pre>";
} else {
    unset($_POST['backup']);
}
?>
    </td>

        </td>
        
        <td><br>
    <center><h3><font size="6">Daftar Pasien Tanggal 
开发者ID:novitasa,项目名称:clinic,代码行数:31,代码来源:adminByDate.php

示例11: pageBackup

/**
 * Display the 'Backup' page.
 */
function pageBackup()
{
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    $PIVOTX['template']->assign('title', __('Backup'));
    $PIVOTX['template']->assign('heading', __('Download a zip file containing your configuration files, templates or entries database'));
    $form_backup_cfg = getBackupCfgForm();
    $form_backup_templates = getBackupTemplatesForm();
    $form_backup_database = getBackupDatabaseForm();
    $form_html = $form_backup_cfg->fetch() . $form_backup_templates->fetch() . $form_backup_database->fetch();
    if ($PIVOTX['config']->get('db_model') == "flat") {
        $form_backup_entries = getBackupEntriesForm();
        $form_html .= $form_backup_entries->fetch();
    } else {
        $form_html .= '<p>' . __('NB! Backup the (entries) database using your ISP control panel or the command line.') . '</p>';
    }
    // Which form is used below is irrelevant.
    if ($form_backup_cfg->validate() == FORM_OK) {
        $val = $form_backup_cfg->getvalues();
        if ($val['what'] == 'config' || $val['what'] == 'entries' || $val['what'] == 'templates' || $val['what'] == 'db-directory') {
            backup($val['what']);
            // The script stops here - the backup starts the download.
        } else {
            debug("Unknown page action");
            return;
        }
    }
    $PIVOTX['template']->assign("form", $form_html);
    $PIVOTX['template']->assign("html", $html);
    renderTemplate('generic.tpl');
}
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:35,代码来源:pages.php

示例12: publish

function publish($siteid, $version, $description, $filename, $md5, $type)
{
    global $cfg, $data, $versions, $ext;
    $rt = array('result' => false, 'error' => -1);
    $debug = '1';
    $list = getList(false);
    $site = $list[$siteid];
    //$debug= json_encode($site);
    //$debug = $description;
    //file_put_contents("debug.log", strtolower(md5_file($filename)))
    //file_put_contents("debug.log", strtolower(md5_file($filename)))
    if ($site != null && file_exists($filename) && strtolower(md5_file($filename)) == strtolower(trim($md5))) {
        if ($site['current_version'] == $version) {
            //10 publish 发布版本和线上版本一致
            $rt['error'] = 10;
            return $rt;
        }
        //检查目标路径
        $p = $site['root'] . $version;
        $tmp = $cfg['tmp_unzip'] . getRandomName($siteid . '_' . $version . '_tmp/');
        if (file_exists($p)) {
            //如果存在则备份配置
            //删除已经存在的文件目录
            if ($site['backup']) {
                backup($p, $site['backup'] . getRandomName($siteid . '_' . $version . '.zip'));
            }
            $r = delDirAndFile($p);
            if ($r == 0) {
                $debug = $p;
                //9 publish 目录创建失败
                $rt['error'] = 9;
            }
        }
        if ($site['upload']) {
            //备份上传文件
            copy($filename, $site['upload'] . str_replace($cfg['tmp_upload'], '', $filename));
        }
        if ($rt['error'] == -1) {
            if (!mkdir($p) || !mkdir($tmp)) {
                //9 publish 目录创建失败
                $debug = $p . ' ' . $tmp;
                $rt['error'] = 9;
            } else {
                if ($type && strtolower($type) == 'copyreplace') {
                    //拷贝当前版本
                    FileUtil::copyDir($site['root'] . $site['current_version'], $p, true);
                }
                //解压缩文件到临时目录
                $z = new ZipArchive();
                //die(file_exists($filename));
                $z->open($filename);
                $z->extractTo($tmp);
                //将临时目录下的deploy目录拷贝到目标路径
                if (file_exists($tmp . 'deploy')) {
                    //将部署程序从deploy目录下拷贝到目标路径
                    FileUtil::copyDir($tmp . 'deploy', $p, true);
                    if ($versions[$siteid] == null) {
                        $versions[$siteid] = array();
                    }
                    $intver = intval($version);
                    $versions[$siteid][$intver] = array('version' => $intver, 'description' => $description, 'date' => date("Y-m-d H:i:s", time()));
                    save_records($data, $ext, $versions);
                    $rt['error'] = 0;
                    $rt['result'] = true;
                } else {
                    $rt['error'] = 7;
                    $debug = '上传文件无deploy目录';
                }
                //删除临时目录
                /*
                FileUtil::unlinkFile($filename);
                FileUtil::unlinkDir($tmp);
                */
            }
        }
    } else {
        //8 publish upload md5 校验失败
        $rt['error'] = 8;
    }
    $rt['msg'] = $debug;
    return $rt;
}
开发者ID:zeus911,项目名称:versionSwitchTool,代码行数:82,代码来源:index.php

示例13: date

                $log .= date('Y-m-d H:i:s') . "已成功存储到云端" . $ret['filename'] . "\r\n";
            } else {
                $log .= date('Y-m-d H:i:s') . "存储到云端失败" . $ret['filename'] . "\r\n";
            }
            unlink('./' . $ret['filename']);
            break;
        case '2':
            //仅本地
            $log .= date('Y-m-d H:i:s') . "已存储到本地" . $ret['filename'] . "\r\n";
            break;
        case '3':
            ///云端和本地
            $log .= date('Y-m-d H:i:s') . "已存储到本地" . $ret['filename'] . "\r\n";
            $sendok = $file::sendfile($ret['filename']);
            if ($sendok) {
                $log .= date('Y-m-d H:i:s') . "已成功存储到云端" . $ret['filename'] . "\r\n";
            } else {
                $log .= date('Y-m-d H:i:s') . "存储到云端失败" . $ret['filename'] . "\r\n";
            }
            break;
        default:
            $log .= "备份参数不正确\r\n";
            break;
    }
    return $log;
}
if ($_GET['key'] == PASS) {
    $log = backup();
    echo $log;
    file_put_contents('log.log', $log, FILE_APPEND);
}
开发者ID:joyerma,项目名称:backup,代码行数:31,代码来源:backup.php

示例14: outputToJSON

    if (empty($newData) || $newData == '[]') {
        outputToJSON(array('error' => true, 'desc' => 'will not erase'));
    }
    //actual query
    $params = array(':data' => $newData, ':datetime' => date("Y-m-d H:i:s"));
    $query = "UPDATE vaultage_data SET\r\n\t\t\t\t\t\t\t`last_update` =:datetime,\r\n\t\t\t\t\t\t\t`data`       =:data";
    $req = $db->prepare($query);
    $res = $req->execute($params);
}
/*
 * This will send a backup by mail if the option is enabled
 */
function backup($data)
{
    if (MAIL_BACKUP_ENABLED) {
        $header = "From: \"JWHITE-SERVER\"<jwhite@jwhitech.homeip.net>\n";
        $header .= "MIME-Version: 1.0\n";
        $corpus = "" . $data . "\n\n[EOF]\n";
        $res = mail(BACKUP_EMAIL, BACKUP_SUBJECT, $corpus, $header);
    }
}
//main
auth();
$db = dbSetup();
$data = getLastCipher($db);
if (isset($_POST['data'])) {
    writeNewCipher($db, $_POST['data']);
    $data = getLastCipher($db);
    backup($data[0][0]);
}
outputToJSON(array('error' => false, 'data' => $data[0][0]));
开发者ID:Software-js,项目名称:Passwords,代码行数:31,代码来源:core.php

示例15: header

#
#
#
#
#
#
#
#
require "settings.php";
header("Location: company-export.php");
exit;
# decide what to do
if (isset($_POST["key"])) {
    switch ($_POST["key"]) {
        case "backup":
            $OUTPUT = backup($_POST);
            break;
        default:
            $OUTPUT = comfirm();
    }
} else {
    $OUTPUT = confirm();
}
require "template.php";
# confirms
function confirm()
{
    $confirm = "<h3>Making a new Backup will delete the previous backup.</h3>\r\n<br>\r\n<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n<form action='" . SELF . "' method=post>\r\n<input type=hidden name=key value=backup>\r\n\r\n<tr><td colspan=2 align=right><input type=submit value='Backup &raquo;'></td></tr>\r\n</form>\r\n</table> <p>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t<tr><th>Quick Links</th></tr>\r\n        <script>document.write(getQuicklinkSpecial());</script>\r\n        <tr class='bg-odd'><td><a href='main.php'>Main Menu</a></td></tr>\r\n\t</table>\r\n";
    return $confirm;
}
# Select Month
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:31,代码来源:backup-make.php


注:本文中的backup函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。