I have an SQL Server 2005 Enterprise Edition whose Maintenance plan fails constantly with the error:
backup MYSERVER (MYSERVER)
Backup Database on MYSERVER
Databases that have a compatibility level of 70 (SQL Server version 7.0) will be skipped.
Databases: All databases
Type: Differential
Append existing
Task start: 2011-10-18T00:10:09.
Task end: 2011-10-18T00:10:09.
Failed:(-1073548784) Executing the query "BACKUP DATABASE [model] TO DISK = N'\\myNetworkDrive\\opovo\\BackupSQL\\MYSERVER\\model\\model_backup_201110180010.bkp' WITH DIFFERENTIAL , RETAINDAYS = 13, NOFORMAT, NOINIT, NAME = N'model_backup_20111018001008', SKIP, REWIND, NOUNLOAD, STATS = 10
" failed with the following error: "Cannot open backup device 'C:\\Program Files\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Backup\\Arca\\opovo\\BackupSQL\\MYSERVER\\model\\model_backup_201110180010.bkp'. Operating system error 3(The system cannot find the path specified.).
BACKUP DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
But the query:
BACKUP DATABASE [model] TO DISK = N'\\myNetworkDrive\\opovo\\BackupSQL\\MYSERVER\\model\\model_backup_201110180010.bkp' WITH DIFFERENTIAL , RETAINDAYS = 13, NOFORMAT, NOINIT, NAME = N'model_backup_20111018001008', SKIP, REWIND, NOUNLOAD, STATS = 10
runs normally and gives me the expected results.
Is this a bug?
What am I missing here?
What is the elegant way to backup to a network location?
You need to check the account that SQL Server Agent service runs as. If the account doesn't have permissions on that network share, then it won't be able to see that path. Executing that query outside of a SQL Server Agent job (indirectly through a maintenance plan) doesn't use the security context of the SQL Server Agent service.
Make the SQL Server Agent service run as a domain account with access to that network share.
Related
I have a backup issue in sql server. Backup plans are stopping working in first step of backup job.
this is the error description
Backup.LOG,,,The job failed. The Job was invoked by User sa. The last step to run was step 1 (LOG)
Server is have 500 gb of free storage. There is no disk error or low memory warning.
i have checked backup plans and checked if there is a read only protection on the disk but there isnt.
Solved it. Job Activity monitor is not detailed and it says only "An error occurred". I found the error in this directory:
C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log
One of the databases are offline and SQL Server can't back it up. I deleted the offline database from the backup settings and it's working.
My objective is to backup a remote SQL Server database using SQL Server command line tools for Mac (or Linux). After installing the sqlcmd utility, I am able to connect to the database but am not sure how to handle the TO DISK command, whose default is to assume a Windows operating system.
sqlcmd -S myserver.com -U AIS -Q "BACKUP DATABASE mydb TO DISK = N'/mybackups/mydb.bak' WITH NOFORMAT, NOINIT, NAME = 'mydb', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
This command returns the error:
Cannot open backup device 'D:\BACKUP\mybackups\mydb.bak'. Operating system error 3 (The system cannot find the path specified).
I have tried changing access permissions of the folder mybackups using chmod 777 mybackups but the same error is still thrown. Any idea about how to solve this?
Used SQL Server Management Studio to restore a database but "Take tail-log backup with NORECOVERY" was checked and user didn't have permission to RESTORE database.
So T-SQL commands executed in this order (generated in SQL Server Management Studio):
BACKUP LOG [database]
TO DISK = N'...DatabaseBackup_2016-08-28_14-07-05.bak'
WITH NOFORMAT, NOINIT,
NAME = N'...DatabaseBackup_2016-08-28_14-07-05', NOSKIP, NOREWIND,
NOUNLOAD, NORECOVERY, STATS = 5
Executed OK
RESTORE DATABASE [database]
FROM DISK = N'....database.bak'
WITH FILE = 1.....
Failed (User doesn't have right for RESTORE)
RESTORE DATABASE <database> WITH RECOVERY
doesn't work because of permission
So the question is how to release database from restoring state and how did the server allow me to set database into restoring state without permission?
Permissions for BACKUP and RESTORE operations are different.
https://msdn.microsoft.com/en-us/library/ms186858.aspx
https://msdn.microsoft.com/en-us/library/ms186865.aspx
, so the user may have permissions to backup the log and put it into restoring mode, but may not have permissions to restore the database.
Modify the user permissions, it should work.
I created the database on SQL Server 2008 and connect to it
{.ConnectionString = "Server=.\SQLEXPRESS;Database=Test;User=sa;Pwd=test;"}
Now i want to deploy that application so my friend can test it. I have no idea how to make it possible or is it possible at all ( is the database on my localhost ) ?
I would really could use some help because first time working with it.
You can create local mdf database file in your project and slightly change your connection string to attach it to sqlexpress instance.
"Data Source=.\SQLEXPRESS;
AttachDbFilename=test.mdf;
Integrated Security=True;
User Instance=True";
It worth to mension that your friend has to have sql server express installed.
I think the best way is to make a backup of your DB as follows.BACKUP DATABASE [Accounting] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Test.bak' WITH NOFORMAT, INIT, NAME = N'Accounting-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
then they can restore it as follows on there mssqlserver:
RESTORE DATABASE [DBRooiabooking] FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Test.bak' WITH FILE = 1, NOUNLOAD, STATS = 5
and they can use it .
with the same connectionstring .
Best Regards
With SQL Server 2005 Express (obeserved on XP and Server 2003), I get sometimes huge Error logs files in production:
The file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG grows to fill the disk (file size becomes more than 15 GB).
This file is not the transaction log, just the error log : a text log for SQL Server.
The error log starts like this: (seems to be normal)
2009-01-11 09:16:57.04 spid51 Starting up database 'SDomain'.
2009-01-11 10:04:34.21 spid21s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'Object Plans' cachestore (part of plan cache) due
to some database maintenance or reconfigure operations.
2009-01-11 10:04:34.23 spid21s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'SQL Plans' cachestore (part of plan cache) due to
some database maintenance or reconfigure operations.
2009-01-11 10:04:34.23 spid21s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'Bound Trees' cachestore (part of plan cache) due t
o some database maintenance or reconfigure operations.
2009-01-11 10:08:37.32 spid51 Starting up database 'SDomain'.
2009-01-11 10:56:55.48 spid22s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'Object Plans' cachestore (part of plan cache) due
to some database maintenance or reconfigure operations.
2009-01-11 10:56:55.49 spid22s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'SQL Plans' cachestore (part of plan cache) due to
some database maintenance or reconfigure operations.
2009-01-11 10:56:55.49 spid22s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'Bound Trees' cachestore (part of plan cache) due t
o some database maintenance or reconfigure operations.
2009-01-11 11:00:07.51 spid51 Starting up database 'SDomain'.
2009-01-11 11:47:44.73 spid15s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'Object Plans' cachestore (part of plan cache) due
to some database maintenance or reconfigure operations.
2009-01-11 11:47:44.74 spid15s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'SQL Plans' cachestore (part of plan cache) due to
some database maintenance or reconfigure operations.
2009-01-11 11:47:44.74 spid15s SQL Server has encountered 1 occurrence(s) of cachestore flush for the 'Bound Trees' cachestore (part of plan cache) due t
o some database maintenance or reconfigure operations.
Then the file seems to contain endlessly repeating lines like this:
2008-12-17 00:12:24.03 spid13s The log for database 'SDomain' is not available. Check the event log for related error messages. Resolve any errors and restart the database**
FYI, the windows eventlog contains exactly the same messages.
Any idea of the reason why this problem occurs? Could it be a particular issue of configuration of SQL Server? Or an issue in code causing this?
You have a database named SDomain that is set to auto-close. Whenever is accessed, it is 'started'. Recently you, or someone near you, deleted or moved the LDF file of the database. When the process that is accessing the SDomdain database is trying to open it, SQL Server will complain about the problem in the ERRORLOG. Give the database back its LDF and will stop complaining. Execute sp_cycle_errorlog to start a new ERRORLOG file so you can delete the old one.
Maybe this can help? http://support.microsoft.com/kb/917828
The common reasons why a database would start recovering on its own are:
The SQL Service was shutdown from the Service Control Manager or due a server shutdown
A fatal error occurred on the database which forced SQL Server to shut down the database and recover it
Someone manually initiated a recovery on the database using RESTORE WITH RECOVERY command
A database backup was restored onto the database
During this phase your database will not respond to any user requests. Only once the recovery phase is complete will the database be accessible to users.
To find out why this happened you might want to check the SQL Server ERRORLOG and find out what find right before the recovery started on the database. Any fatal errors or database restore operations would be logged in the SQL Server ERRORLOG.
Also check if Auto Close option is enabled for your database. If thats true you need to turn off that option as follows,
Right click the database.
Select Properties
Click on Options.
AutoClose is the first option and ensure that it is marked as False.
Ensure user account servername\SQLServer2005MSSQLUser$servername$SQLEXPRESS has write access to the directory that your database is residing in.