Hi, I am using a .bat file to initiate a .sql file which backs up our database. It is in the Task Scheduler to run every single day, however I’ve just noticed that it seems to skip days out randomly and I can’t find out why. The Task Scheduler seems to run every day, but there isn’t a new backup file every day.
The database polls a different system every half hour and updates the database if there are new items in the other system. I was thinking that this updating was getting in the way, but the evidence doesn’t seem to back it up (the backup runs at 8pm and on one of the failed days there was a download at 7:59pm so I thought that makes sense. But then another failed day there was no downloads an hour either side of 8pm)
Does anyone have any suggestions please? Here is my backup code…
DECLARE @Odyssey NVARCHAR(4000)
SET @MyDatabase = ‘C:\Program Files (x86)\MyDatabase\Backup\MyDatabase’+REPLACE(REPLACE(CONVERT(varchar(100), GETDATE(), 100),’:’,’’),’ ‘,’’)+’.bak’
BACKUP DATABASE [MyDatabase] TO DISK = @MyDatabase WITH NOFORMAT, INIT, NAME = N’MyDatabase-Full Database Backup’, SKIP, NOREWIND, NOUNLOAD, STATS = 10