I have a database on SQL Server 2008 R2 SP2, I have this backup plan on that db:
every Friday morning I get a full backup of my db and at noon I get differential backup and the other days of the week I get differential backup twice per day (morning and noon).
The full backup size is about 50 GB. My problem is: the first differential backup size is about 42 GB.
I have no jobs in the time between the full and differential backup and there is no any rebuild index, reorganize index or update stats and the transaction on this db is not more.
In order to test, I get a full backup from db and after this done, I get differential backup from that immediately but the differential backup size is about 42 GB.
Even if I check the DCM page content and after getting full backup this page is reset.
I don't know what is the problem.
Here are my backup commands:
Full backup:
BACKUP DATABASE [test]
TO DISK = N''filePath\test.bak''
WITH NOFORMAT, NOINIT, NAME = 'test', SKIP, REWIND,
NOUNLOAD,COMPRESSION, STATS = 10
DIFF Backup
BACKUP DATABASE [test]
TO DISK = N''filePath\test.bak''
WITH DIFFERENTIAL, NOFORMAT, NAME = 'testdiff', NOINIT, SKIP, REWIND,
NOUNLOAD, STATS = 10
You are specifying NOINIT clause.
Indicates that the backup set is appended to the specified media set, preserving existing backup sets. If a media password is defined for the media set, the password must be supplied. NOINIT is the default.
Your files will keep growing as new backups are being appended.
Also your post does not mention when and how you backup the log. I hope this is only an omission, as log needs to be backed up too.
BACKUP DATABASE [test] TO DISK = N''filePath\test.bak'' WITH DIFFERENTIAL, NOFORMAT, NAME = testdiff',NOINIT, SKIP, REWIND, NOUNLOAD, STATS = 10
in the Statement above I've used NOINIT, naturally the new backup file must be appended to the previous file but because I use the new name for my new backup file, the new file will be created and it won't appended to previous file.
But my problem has been solved. because I had replication on my DB before and after removing it the publication had remained in the SQL instance and there was an active transaction(Replication) on my db so it locks many of the transaction logs and many of my VLFs were active.they were waiting to send to subscriber server.
after removing publication from my SQL instance the VLF files set to 0 and the transaction log file has been shrink So, the differential backup file size were decreased.
Related
I am trying to copy a live database from one instance to a development instance for debugging purposes
The live database is ~200M in size running on on SQL Server 2008 R2 (10.50.4042)
I have tried numerous ways of backing up and restoring, but every time the Restore gets 100% and just sits there
I have tried SQLServer 2016 Developer and SQLServer 2008 R2 Express as development instance , same result
The database is very simple, but something is blocking the restore
BACKUP DATABASE [database] TO DISK = N'D:\file.BAK'
WITH NOFORMAT, NOINIT, NAME = N'Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 5*
The backup literally takes seconds takes seconds, even with compression off it is only 200M in size
The restore takes a few seconds to restore but then just sits at 100%
I have read many articles , none work so tried RECOVERY NORECOVERY
Tried to kill and restore, tried to mount, nothing seems to work.
What other options are there?
RESTORE DATABASE [database] FROM DISK = N'D:\File.BAK' WITH FILE = 1, MOVE N'Instance_Data' TO N'D:..\database.mdf', MOVE N'Instance_log' TO N'D:..\database_1.ldf', NOUNLOAD, RECOVERY, STATS = 5
Live database for Rows Data = 173 MB, the LOG 161,574 MB
One .bak file:
BACKUP DATABASE dbName TO DISK = C:\dbname.bak 1200 MB
How to backup Microsoft SQL Server database into multiple .bak files, splinting it to multiple files like DBName01.bak,DBName02.bak,....'DBName0N.bak there N is parameter for number of files.
Where N would be dynamic parameter.
Yes you can take your backups to multiple files, its actually more convenient to have smaller files rather than having one large file.
The syntax for taking backups to multiple files would be:
BACKUP DATABASE [dbName] TO
DISK = N'D:\backups\MultipleFiles\MyDB_Backup_File1.bak',
DISK = N'D:\backups\MultipleFiles\MyDB_Backup_File2.bak',
DISK = N'D:\backups\MultipleFiles\MyDB_Backup_File3.bak'
WITH NOFORMAT, NOINIT, NAME = N'dbName-Full Database Backup'
, SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
The data is distributed equally among all the files, so if you want smaller files use more files to take backups.
Heyo,
This question is quite simple. I have a T-SQL backup script run by SQL Server Agent.
A differential backup is taken every hour, bar once per day, when a full is taken.
After either differential or full, a transaction log is backed up.
In addition, every 10 minutes, the transaction log solely is backed up again.
I save the transaction log with the date including the hour in the file name; in other words, output to the same filename 6 times an hour, then a new transaction log file is made.
Should I be saving to the same file 6 times per hour? Is SQL by default appending to the log or is it overwriting? Will restore operations be more complicated with multiple backups in one file?
For completeness, here is the log backup statement:
BACKUP LOG #db
TO DISK = '\\somedrive\path\sqlservername\yymmdd-hh.trn'
WITH NAME='Log network backup.', DESCRIPTION='long backup description with time, DB and server name'
The server versions are SQL 2008 R2 and SQL 2012.
we have a large SQL db that we split into 4 separate bak files in a nightly backup so it can be more easily sent offsite. We use this statement (db names changed)
BACKUP DATABASE [Data] TO
DISK = 'd:\back\data1.bak',
DISK = 'd:\back\data2.bak',
DISK = 'd:\back\data3.bak',
DISK = 'd:\back\data4.bak'
WITH INIT, NOUNLOAD, NAME = 'Data backup', NOSKIP , STATS = 10, NOFORMAT
All four of the backups have the same logical names for the mdf and ldf files in the bak.
I want to be able to restore these four backups into a different database on the server for testing. I found a t-sql script in this post which I think will do this but I am not sure. Can someone help?
I'm thinking I could adapt and run the script as follows:
RESTORE DATABASE Data_test FROM
DISK = 'd:\back\data1.bak',
DISK = 'd:\back\data2.bak',
DISK = 'd:\back\data3.bak',
DISK = 'd:\back\data4.bak'
WITH MOVE 'Prod_Data' TO 'D:\SQLDb\Data_Test1.mdf',
MOVE 'Prod_Data' TO 'D:\SQLDb\Data_Test2.ndf',
MOVE 'Prod_Data' TO 'D:\SQLDb\Data_Test3.ndf',
MOVE 'Prod_Data' TO 'D:\SQLDb\Data_Test4.ndf',
MOVE 'Prod_Log' TO 'C:\SQLtlogs\Data_test1.ldf'
Do you think this would work? And will this test db not conflict with the prod db from which it was restored? Any help would be great, thanks.
OK, I actually got this to work with the GUI for SSMS. All you have to do is choose Tasks, Restore Database, choose from device, then add all four files of the separate bak files, then click OK and do the restore with Overwrite, modifying the file names for mdf and ldf as needed so they are for the test db and not production. SSMS knows the four files are part of the same media set and reassembles them into the mdf and ldf file. Looks like I did not need a script after all.
I used this TRANSACT-SQL command to do almost the same thing you requested. The only difference is that I was only moving each logical file to a single physical file. My command (modified to use your example) looks like this:
RESTORE DATABASE Data_test FROM
DISK = 'd:\back\data1.bak',
DISK = 'd:\back\data2.bak',
DISK = 'd:\back\data3.bak',
DISK = 'd:\back\data4.bak'
WITH MOVE 'Prod_Data' TO 'D:\SQLDb\Data_Test1.mdf',
MOVE 'Prod_Log' TO 'C:\SQLtlogs\Data_test1.ldf'
I have this script to backup my sql server 2000 database:
BACKUP DATABASE [CRM] TO DISK = N'd:\CRM_BACKUP\crm.bak'
WITH NOINIT, NOUNLOAD, NAME = N'GUY_CRM_BACKUP', NOSKIP, STATS = 10, NOFORMAT
I want the backup to be for several days.
I thought about giving the name of the backup the day of the month
e.g. crm01.bak, crm02.bak.... crm30 or crm31.bak.
How can I do that please?
TIA
Guy
You can set RETAINDAYS to the number of days you wish to keep that backup. Since you are using NOSKIP (and NOFORMAT), SQL Server will not overwrite that backup until it has expired. At that point, you could also institute a naming standard like you are mentioning, or set a maintenance plan to erase backups older than a certain age.