SQL Server中的Forwarded Record計數器影響IO機能的處理辦法。本站提示廣大學習愛好者:(SQL Server中的Forwarded Record計數器影響IO機能的處理辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是SQL Server中的Forwarded Record計數器影響IO機能的處理辦法正文
中小站點簡略備份戰略
基於drupal的中小行網站,我們可使用backup_migrate模塊,該模塊供給了按期備份的功效,備份的時光、保存若干個備份等等設置,設置好以後,按期履行cron便可備份勝利。 普通的Drupal小站,我們只需應用svn便可,在辦事器端,我們把備份好的數據提交到svn,便可以到達備份的目標。因為Drupal的備份模塊可以設置備份保存的文件份數,是以不會形成太多的備份文件,從而招致svn很年夜。
上面是一個簡略的備份劇本,放置到站點根目次,然後加到crontab天天履行便可。
#!/bin/bash date #start date DRUSH_PHP=/bin/php #php path export DRUSH_PHP drush cron svn st sites/default/files/backup_migrate/scheduled/ | grep '^!' | awk '{print $2}' | xargs svn delete --force svn add sites/default/files/backup_migrate/scheduled/* svn ci sites/default/files/backup_migrate/scheduled/ -m 'add backup files' date #end date
crontab的設置以下
0 0 * * * cd /www/web/html/ && bash cron.sh > cron.log 2>&1
年夜型站點MySQL備份戰略
假如是數據庫稍年夜的站點,應用svn暫時備份就略顯薄弱,這時候須要應用MySQL備份戰略,普通情形下我們須要把全部數據庫都備份緊縮,然後按期轉移到備份數據庫或許放到其他的雲辦事器,這裡給出一個簡略的PHP示例代碼。
#!/usr/bin/php -q <?php $to = "[email protected]"; $hostname = exec('/bin/hostname'); $mycnf = "/home/robbin/.my.cnf"; $ignore = array('information_schema', 'test', 'mysql', 'wdcpdb'); function trimw($str) { $str = str_replace(array("n", "r", "t", " ", "o", "xOB"), '', $str); return $str; } if (!file_exists($mycnf)) { mail($to, "No .my.cnf exists on $hostname", "MySQL cannot dump because .my.cnf is missing on $hostname .") ; exit("cant get user creds"); } $myconf = file_get_contents($mycnf) or die( "Failed to open bmesh_admin's .my.cnf" ); preg_match( "/buser(.*)/", $myconf, $matches ) or die( mail($to, "No username in .my.cnf on $hostname", "MySQL cannot dump on $hostname")); $usr = (explode('=', $matches[0])); $user = trimw($usr[1]); preg_match( "/bpassword(.*)/", $myconf, $matches ) or die( mail($to, "No password in .my.cnf on $hostname", "MySQL cannot dump on $hostname")); $pass = (explode('=', $matches[0])); $password = trimw($pass[1]); mysql_connect("localhost",$user,$password) or die ("could not connect: " . mysql_error()); mysql_select_db("mysql"); $result = mysql_query("show databases"); $bpath = "/home/robbin/backup/mysql"; $btime = date("Y-m-d H:i:s"); $bstamp = strtotime($btime); $byear = date("Y", $bstamp); $bmonth = date("m", $bstamp); $bday = date("d", $bstamp); $btod = date("H-i-s", $bstamp); while ($res = mysql_fetch_array($result)) { $myDb = $res["Database"]; if (in_array($myDb, $ignore)) continue; $mdir = "$bpath/$byear/$bmonth/$bday/$btod/$myDb"; $out = `mkdir -p $mdir`; $myFile = $myDb . ".sql"; $bldCmd = "cd $mdir ; "; $bldCmd .= "mysqldump -u$user -p$password --single-transaction --add-drop-table -R -c -Q $myDb > $myFile ;"; //$bldCmd .= "chmod 644 $myFile ; "; //$bldCmd .= "chown root:root $myFile ; "; $bldCmd .= "gzip -9 $myFile"; print "Backing up $myDbn"; print "Securing $myDbn"; $out = `$bldCmd`; } $out = `chmod 700 $bpath/$byear`; print "$outn"; print "Backups are in $bpathn";
crontab的設置
0 1 * * * /home/robbin/bin/mysql_backup.php
另外我們須要把備份的數據還要按期傳送到其他辦事器上,才會防止辦事器瓦解而激發數據喪失。備份實時網站才有包管,這裡僅僅只是筆者的一點點操作分享,年夜家有更好的備份戰略,迎接同享。