Skip to content

SQL Server

Backup strategies

1.Set database recovery mode properly.
2.Full backup and log backup.
3.Shrink log file size after backup each time.
4.Check storage available size, delete obsoleted backup files.

How can I recover the database which deleted the log file?

1.Back up the data files via copy.
2.Retrieve the database files paths, including the filenames.
3.Rename data filename.
4.Create the same name and path database.
5.Stop SQL server service.
6.Delete the new data file.
7.Rename the original data file.
8.Startup SQL Server service.
9.Execute SQL as below.

USE MASTER
GO
ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE dbname SET EMERGENCY
DBCC CHECKDB('dbname',REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE dbname SET MULTI_USER;
GO