In first
part, I had covered how to shrink the log file of database. This article
focus on how to take backup of large database in multiple files at different
locations and how to restore them.
Split database into multiple files |
If you asked to any
developer about how to take database backup, they will generally reply - its
very easy. Just use SQL server backup window or use the ready-made script.
But if you asked them take
the backup of 20 GB database and upload on some different machine?
If you are making a single
heavy backup file with 20GB and try to upload on FTP server then it might take
hours. By any chance, this upload operation truncate in between then again you
have to waste your time by uploading the same file on FTP server as well as you
have monitor them now.
Is there any better way?
Yes. SQL server provide a
way where you can split single database into multiple smaller file. Let suppose
you have 20 GB database and now you can take backup in 10 different files and each
file having 2 GB in size.
Here are other advantages of
splitting database into multiple files
- Store each file in different drive or locations.
- ZIP individual file
- Upload individual file on FTP location
Here is a sample script for backup
database in 3 different files at three different locations.
BACKUP DATABASE
SitecoreLessonsSitecore_Master
TO DISK = 'D:\Backup\SitecoreLessonsSitecore_Master\1.bak',
DISK = 'C:\Other_Drive_Backup\SitecoreLessonsSitecore_Master\2.bak',
DISK = 'E:\Daily_Backup\SitecoreLessonsSitecore_Master\3.bak'
GO
Note:- Folder path must exist for successful backup operation.
Use below query to restore
these files
RESTORE DATABASE
[SitecoreLessonsSitecore_Master_Staging]
FROM DISK = N'D:\Backup\SitecoreLessonsSitecore_Master\1.bak',
DISK = N'D:\Backup\SitecoreLessonsSitecore_Master\2.bak',
DISK = N'D:\Backup\SitecoreLessonsSitecore_Master\3.bak'
GO
Note:- Restore work on server where this database is not exist.
You can backup and restore
by using SQL server management studio also. Here is a reference link for it https://solutioncenter.apexsql.com/how-to-create-sql-server-database-split-backup-files/
I have used this backup
script multiple times.
I hope you like this Sitecore database trick. Stay tuned
for more Sitecore articles.
Till that happy Sitecoring
:)
Please leave your comments or share this database trick
if it’s useful for you.
To know more about Sitecore database, Download this eBook.
No comments:
Post a Comment