简体   繁体   English

数据库备份大小难题

[英]Database backup size conundrum

I have a small SQL Server 2005 database. 我有一个小型SQL Server 2005数据库。 I take daily backup (automated) and the size of the .bak file typically comes out to be 400MB, growing by 5MB every day (which is inline with its usages). 我进行每日备份(自动) .bak文件的大小通常为400MB,每天增加5MB(与其用法一致)。

Last night the size of the backup file jumped to 1GB. 昨晚备份文件的大小跃升至1GB。 Suspecting that someone was trying to fill the database with garbage data, I ran a report ( Reports -> Standard Reports -> Disk User By Top Tables ) and the total size came out to be around 400MB. 怀疑有人试图用垃圾数据填充数据库,我运行了一个报告( Reports -> Standard Reports -> Disk User By Top Tables ),总大小约为400MB。

Then thinking maybe something was wrong with the automated backup process, I immediately took backup again but the .bak file came out to be over 1GB. 然后想到自动备份过程可能出了点问题,我立即再次进行了备份,但是.bak文件的大小超过1GB。 Before this automated backup yesterday, an automated task that defragments indexes also ran. 在昨天进行此自动备份之前,还运行了对索引进行碎片整理的自动化任务。 However, all these months, a backup after this index optimization used to actually reduce the size of the .bak file. 但是,在所有这些月中,经过这种索引优化后的备份实际上用于减小.bak文件的大小。

I am trying to find an explanation for this big jump in size overnight and also why the .bak file is more than double the size of the the actual database disk usages? 我正试图找到一种解释,以说明这种大小上的飞跃,以及为什么.bak文件的大小是实际数据库磁盘使用量的两倍以上?

UPDATE: I ran 更新:我跑了

DBCC SHRINKDATABASE(mydb) 

to remove transaction logs. 删除事务日志。 Then took a backup again. 然后再次进行备份。 The size of the .bak file came out even bigger than last time. .bak文件的大小比上一次更大。

This is the query I ran: 这是我运行的查询:

    DBCC SHRINKFILE(mydb_log, 1)
    BACKUP LOG mydbWITH TRUNCATE_ONLY
    DBCC SHRINKFILE(mydb_log, 1)

1 - How are you backing up the data? 1-您如何备份数据? Maintenance plans? 维修计划?

2 - If you are appending to the same database backup file, the backup will grow! 2-如果要追加到相同的数据库备份文件,则备份将增加!

Check out the contents of the file. 检出文件内容。

RESTORE FILELISTONLY FROM AdventureWorksBackups WITH FILE=1;

http://technet.microsoft.com/en-us/library/ms173778.aspx http://technet.microsoft.com/zh-CN/library/ms173778.aspx

This assumes you have a dump device named AdventureWorksBackups. 假设您有一个名为AdventureWorksBackups的转储设备。 You can also change it to a DISK='AdventureWorks.bak'. 您也可以将其更改为DISK ='AdventureWorks.bak'。

3 - Also, the maintenance plans do not do a good job with determining when to re-organize/update stats versus rebuild an index. 3-而且,维护计划在确定何时重新组织/更新统计信息以及重建索引方面做得不好。

4 - Check out the ola hallengren scripts. 4-签出ola hallengren脚本。 They are way better! 他们好多了!

http://ola.hallengren.com/ http://ola.hallengren.com/

First, they create a directory structure for you. 首先,他们为您创建目录结构。

c:\backup\<server name>\<database name>\full
c:\backup\<server name>\<database name>\diff
c:\backup\<server name>\<database name>\log

Second, each backup has a date time stamp. 其次,每个备份都有一个日期时间戳。 No appending to backup files. 没有附加到备份文件。

Third, they clean up after themselves by passing the number of hours to keep on-line. 第三,他们通过保持在线时间来清理自己。

Fourth, they handle index fragmentation better - 5-30 = re-organize or 30+ = rebuild. 第四,他们更好地处理索引碎片-5-30 =重新组织或30+ =重建。

I usually set up the following for my databases. 我通常为数据库设置以下内容。

1 - system databases - full backup every night, log backups hourly. 1-系统数据库-每晚完整备份,每小时记录一次备份。

2 - user databases - full backup 1 x week, diff backup x 6 days, log backups hourly 2-用户数据库-完整备份1 x周,差异备份x 6天,每小时记录日志备份

Last but not least, SQL Server 2005 does not have native support for compressed backups. 最后但并非最不重要的一点是,SQL Server 2005不具有对压缩备份的本机支持。 This does not mean you can not run a batch file to zip them up afterwards. 这并不意味着您之后不能运行批处理文件将其压缩。

Third party tools like QUEST (DELL) and RED GATE used to support their own backup utility. 诸如QUEST(DELL)和RED GATE之类的第三方工具用来支持自己的备份实用程序。 The main reason was to fill this gap. 主要原因是为了填补这一空白。 Since SQL Server 2008, compressed backups were available. 从SQL Server 2008开始,可以使用压缩备份。 I think many of the vendors are getting rid of this utility since it is now standard. 我认为许多供应商都放弃了该实用程序,因为它现在是标准的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM