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.
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
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.
Please advice how can i setup automated database backup in my SQL Server 2012.
I need to take all databases (currently it contains only 3 ) in SQL server an automated weekly backup which runs on Every Friday at 0100 h (1 AM). These back up files (*.bak) should be placed in E:\Backups folder.
In Microsoft SQL Server Management Studio, open the Object Explorer and then:
Right-clic on Management > Maintenance Plans
Clic on New Maintenance Plan...
Give a name to your plan
Create as many subplans as you need for your strategy
Select a subplan and drag'n'drop the appropriate tasks from the Toolbox panel
To backup a database, the appropriate task is Back Up Database Task
For the configuration of the backup schedule, you just need to follow the wizard and define what you want. If you need more information, i suggest you to go on the official website of Microsoft:
Create a Full Database Backup
Hope this will help you
You can either create a SQL Server agent job or maintenance plan in ssms as mentioned, or use a 3rd party application. I use ApexSQL Backup at the moment, as it offers in depth schedule for any created job. You can specify if you want to create daily, weekly or monthly schedule. Besides, you can always pause, or delete these schedules if you don’t want to use them for some reason.
Go to MS SQL Server Management studio→SQL Server Agent→New Job
Under General tab enter Backup name
Under Steps tab:
Type Step name
Select database you want to backup
Enter backup query
Note: Sample backup query here with backup name date and time (e.g. TestBackup_Apr 4 2017 6,00PM.bak)
DECLARE #MyFileName nvarchar(max)
SELECT #MyFileName = (SELECT N'E:\TestbackupFolder\TestBackup_' +replace(rtrim(convert(char,getdate())), ':',',')+ '.bak')
BACKUP DATABASE [yourdatabasename] TO DISK=#MyFileName
WITH INIT;
In Schedules→New, go to new schedule and set date times as required
Check this opensource backup windows service MFSQLBackupService, it did a great job for me.
I can advice you to try the software Cloudberry as a backup agent to backup the data you wish. It sets the automated backup in the way you want to do it and place the backups where you want.
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.
we have a huge (17 gig) MSDE backup file that have discovered has been appending nightly for the last 4 years.
We had a database failure last night and now we need to restore the database.
We tried a standard restore but it restored the database info all the way back to 2008. Which isnt an accurate reflection of the state of the database as it was last backed up.
How do we restore back to just the last backup (or even a date/time) and not all the way back to 2008?
cheers
Buzz
openthe log file, findout the date of the backup you want then use the script
RESTORE DATABASE [restoretest] FROM DISK = N'C:\folder\backfile.bak' WITH FILE = 1494
GO
hurray a working answer.
Buzz