SQLServer备份维护
--SQL Server 数据备份与还原
--假设数据为为MY_DB
--清空日志
DUMP TRANSACTION MY_DB WITH NO_LOG
BACKUP LOG MY_DB WITH NO_LOG
--收缩数据库
DBCC SHRINKDATABASE(MY_DB)
--备份数据主文件
backup database MY_DB To Disk = 'd:\web\backup\MY_DB_BAK' with FORMAT,Name='完整备份MY_DB数据库'
-- 还原数据库Sql2005
RESTORE DATABASE [MY_DB] FROM DISK = N'd:\web\backup\MY_DB_BAK' WITH FILE = 1,
MOVE N'MY_DB' TO N'D:\SqlData\MY_DB.mdf',
MOVE N'MY_DB_log' TO N'D:\SqlData\MY_DB.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO
--假设数据为为MY_DB
--清空日志
DUMP TRANSACTION MY_DB WITH NO_LOG
BACKUP LOG MY_DB WITH NO_LOG
--收缩数据库
DBCC SHRINKDATABASE(MY_DB)
--备份数据主文件
backup database MY_DB To Disk = 'd:\web\backup\MY_DB_BAK' with FORMAT,Name='完整备份MY_DB数据库'
-- 还原数据库Sql2005
RESTORE DATABASE [MY_DB] FROM DISK = N'd:\web\backup\MY_DB_BAK' WITH FILE = 1,
MOVE N'MY_DB' TO N'D:\SqlData\MY_DB.mdf',
MOVE N'MY_DB_log' TO N'D:\SqlData\MY_DB.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO