During Comprehensive Database Performance Health Check, I was recently asked if I have a handy script that can help us take compressed backup and uncompressed backup. Well, of course, I have and here it is. The scripts are very simple.
BACKUP DATABASE [StackOverflow2010] TO DISK = N'D:\backup\Compressed-Backup.bak' WITH COMPRESSION, STATS = 10 GO
Not compressed Backup
BACKUP DATABASE [StackOverflow2010] TO DISK = N'D:\backup\Uncompressed-Backup.bak' WITH NO_COMPRESSION, STATS = 10 GO
When you want to restore either of the back-ups, there is no special command for it. The script for the restore operation is the same for both of them. Here is an example of the same.
RESTORE DATABASE [StackOverflow2010] FROM DISK = N'D:\backup\Compressed-Backup.bak' WITH RECOVERY GO
RESTORE DATABASE [StackOverflow2010] FROM DISK = N'D:\backup\Uncompressed-Backup.bak' WITH RECOVERY GO
I honestly would not spend too much time discussing the performance between the compress and no compress option as this feature is mainly for saving space in your disk. However, here is the observation if you want to discuss the performance of various options.
Compress Backup is smaller in size but took a long time to take backup, however, it was quicker to restore.
No Compress Backup is of the regular size but was faster to take backup, during restore it took a bit longer than compressed backup.
Well, that’s it for today. Would you like me to build a video on this topic? If yes, let me know and I will build a video on this topic on my SQL in Sixty Seconds channel.
Reference: Pinal Dave (http://blog.SQLAuthority.com)