将下面的内容保存为sqlreboot.bat,然后添加到计划任务里,就可以实现一段时间后重启sqlserver服务器了,防止sqlserver经常占用内存过高,导致网页无法打开数据。
复制代码 代码如下:
net stop sqlserveragent
net stop mssqlserver
echo.wscript.sleep(50000)>s.vbs
cscript //nologo s.vbs
del s.vbs
net start mssqlserver
net start sqlserveragent
收缩sqlserver数据库,清空日志文件
复制代码 代码如下:
DUMP TRANSACTION [数据库名] WITH NO_LOG
BACKUP LOG [数据库名] WITH NO_LOG
DBCC SHRINKDATABASE([数据库名])
mysql数据库下实现自动备份并用winrar压缩实现的批处理和php文件
复制代码 代码如下:
FOR /D %%i IN (*) DO D:\php\php5\php.exe -q D:\php\php5\backup.php %%i
backup.php
复制代码 代码如下:
<?php
if ($argc != 2 || in_array($argv[1], array('--help', '-?'))) {
?>
backup Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32
Copyright (C) 2000 ptker All rights reserved.
This is free software,and you are welcome to modify and redistribute it
under the GPL license
PHP Shell script for the backup MySQL database.
Usage: <?php echo $argv[0]; ?> <option>
<option> can be database name you would like to backup.
With the --help, or -? options, you can get this help and exit.
<?php
} else {
$dbname = $argv[1];
$dump_tool = "D:\\php\\mysql\\bin\\mysqldump.exe";
$rar_tool = "D:\\program\\winrar\\rar.exe";
$dateml=date("Ymd");
$yesday=date('Ymd' , strtotime('-6 day'));
@exec("md F:\\sqldata\\mysqlbak\\$dateml");
@rmdir("F:\\sqldata\\mysqlbak\\$yesday");
//@exec("$dump_tool --single-transaction --opt -u root -pxzqcABCD986 $dbname > ./$dbname.sql");
//@exec("$rar_tool a -ag_yyyy_mm_dd_hh_mm F:\\sqldata\\mysqlbak\\{$dateml}\\$dbname.rar $dbname.sql");
@exec("$rar_tool a -ag_yyyy_mm_dd_hh_mm F:\\sqldata\\mysqlbak\\{$dateml}\\$dbname.rar D:\\php\\mysql\\data\\$dbname");
@rmdir($dbname);
echo "Backup complete!";
}
?>
复制代码 代码如下:
net stop sqlserveragent
net stop mssqlserver
echo.wscript.sleep(50000)>s.vbs
cscript //nologo s.vbs
del s.vbs
net start mssqlserver
net start sqlserveragent
收缩sqlserver数据库,清空日志文件
复制代码 代码如下:
DUMP TRANSACTION [数据库名] WITH NO_LOG
BACKUP LOG [数据库名] WITH NO_LOG
DBCC SHRINKDATABASE([数据库名])
mysql数据库下实现自动备份并用winrar压缩实现的批处理和php文件
复制代码 代码如下:
FOR /D %%i IN (*) DO D:\php\php5\php.exe -q D:\php\php5\backup.php %%i
backup.php
复制代码 代码如下:
<?php
if ($argc != 2 || in_array($argv[1], array('--help', '-?'))) {
?>
backup Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32
Copyright (C) 2000 ptker All rights reserved.
This is free software,and you are welcome to modify and redistribute it
under the GPL license
PHP Shell script for the backup MySQL database.
Usage: <?php echo $argv[0]; ?> <option>
<option> can be database name you would like to backup.
With the --help, or -? options, you can get this help and exit.
<?php
} else {
$dbname = $argv[1];
$dump_tool = "D:\\php\\mysql\\bin\\mysqldump.exe";
$rar_tool = "D:\\program\\winrar\\rar.exe";
$dateml=date("Ymd");
$yesday=date('Ymd' , strtotime('-6 day'));
@exec("md F:\\sqldata\\mysqlbak\\$dateml");
@rmdir("F:\\sqldata\\mysqlbak\\$yesday");
//@exec("$dump_tool --single-transaction --opt -u root -pxzqcABCD986 $dbname > ./$dbname.sql");
//@exec("$rar_tool a -ag_yyyy_mm_dd_hh_mm F:\\sqldata\\mysqlbak\\{$dateml}\\$dbname.rar $dbname.sql");
@exec("$rar_tool a -ag_yyyy_mm_dd_hh_mm F:\\sqldata\\mysqlbak\\{$dateml}\\$dbname.rar D:\\php\\mysql\\data\\$dbname");
@rmdir($dbname);
echo "Backup complete!";
}
?>
标签:
服务器,批处理,数据库
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
内蒙古资源网 Copyright www.nmgbbs.com
暂无“服务器常用批处理代码 原创”评论...