I've created an agent job in SQL Server 2008 with steps:
Backup
Transfer File (to another server)
Restore (to another server)
Step 1 backup has been successful, but when process transfers the file, it fails with message
invalid drive specification
I've added IP of destination server on Windows credential, and I try to run the syntax in CMD it works:
exec xp_cmdshell 'xcopy D:\folder\file_name*.ext \\desination_IP\folder\'
When I try with SQL Server 2017, it works. Is there any difference between 2008 and 2017? Please let me know
Then go to the next step restore, what I want is to restore the database from server A to server B. Example I have 2 servers with the name A server and B server i put the job in A server and the job consists of step backup, step transfer file and step restore. I transfer db to B server then i want to restore database in B server from A server with agent.
The question is, is that possible? Can somebody help me with the query to restore a database from another server? Thanks
Check to see what user the SQL Agent service is running as, if it is Local System, you'll need to change it to an account that has access to the destination folder.
Related
I need some help as I am unable to log into a database.
Some Error is coming like...
unable to start service MS SQL SERVER ON SERVER SERVER.(MSCORLIB)
A network-related or instance-specific error occurred while establishing a connection to sql server.
The server was not found or was not accessible. verify that the instance name is correct and that sql server is configured to allow remote connections.(provider: name pipes provider, error 40 could not open a connection to sql server) (Microsoft sql server, error :2)
My question is how can I take the backup now because I am unable to login into the sql.
As you have event in 9003 in your Event Log it indicates that you have corrupted master datatbase and you will need to rebuild it.
First check your disks for errors and fix them.
Then you will need to rebuild the master database:
For SQL Server 2005 check this:
http://www.sqlcoffee.com/Troubleshooting007.htm
or
http://thedbavault.blogspot.cz/2013/01/ms-sql-server-2005-rebuild-master.html
Also some recommend to use database file from another instance of the same version of SQL Server.
http://blogs.technet.com/b/fort_sql/archive/2011/02/01/the-easiest-way-to-rebuild-the-sql-server-master-database.aspx
Then you should be able to restore non-corrupted backup copy of your master database.
If you do not have backup of your master database, then you will have to recreate all logins, users, roles, permissions etc.
To backup data without running SQL Server you can only backup database files .mdf, .ldf.
After applying Update 2 - the Scheduled Backup is now a build-in feature (not requiring Power Tool). I have difficult understanding the required permissions required to dump a backup on a file-share. Even when trying to dump the backup on a local share - \mytfs2012server\c$\Backup - the wizard ends up with a:
TF401002: The SQL Server Database Engine failed to save the database backup to path... Please grant SQL service account read/write access to that folder.
The message is very simple. I have tried different things - without success. With Update 1 + Power Tools I succeeded to use the wizard after some tweaking. Anyone that can list the permissions required for the Scheduled Backup for Update 2?
Edit:
Update 3 did not change anything for me. However it looks like Update 4 will. From this page it looks like Update 4 will include changes regarding backup:
Scheduled Backups configuration is no longer blocked if the SQL Server service for TFS 2012 is running as a virtual account (for example: NT Service\MSSQLSERVER).
In TFS 2012 Update 2 and Update 3, transactional backups record a failure when they try to run while a full or differential backup is running.
Scheduled Backups no longer run transactional backups if a full or differential backup is running. Instead, the job will be suspended until the other backup has finished running.
I had the same Problem.
Infrastuctur: TFS 2012 Update 2, SQL Server 2012
Solution:
I created a simple shared Folder like \BACKUPSERVER\TFS_Backup$ on the DB Backup Server.
I configured the TFS admin and the SQL Admin with Full Control in the Security and Share Permissions.
Now the Backup Job is running.
But now i have an other Problem:
After running a Full Backup the Transaction-Logs were not truncated, does any one have the same Problem or maybe an solution?
Are you using virtual accounts for the server? Something like 'NT Service\MSSQLSERVER'? If so be aware that they aren't supported in the Scheduled Backups Wizard in both TFS 2012.2 & 2012.3.
You either have to create the backup plans manually or switch the SQL service account to a domain account or Network Service.
EDIT:
As per the comments, TFS 2012.4 RC2 and up has removed this restriction
I want to export database from local computer to database server in SQL Server 2005.
How can I restore database without having access to file system of database server
You can use SQL Server's built-in backup and restore functions.
Make a backup of your local database, and write it on some network share (can be anywhere in the network, doesn't have to be on the database server):
BACKUP DATABASE MyDatabase TO DISK = '\\Servername\Share\MyBackup.bak'
Then, you can restore the database on the database server, reading the backup directly from the network share:
RESTORE DATABASE MyDatabase FROM DISK = '\\Servername\Share\MyBackup.bak'
Note that you have to everything in T-SQL to be able to read and write directly to network shares!
(You can also backup and restore databases from the GUI in SQL Server Management Studio, but you can only use local folders there)
Your situation is, you want to copy the database from your local to remote database server but you do have access to the remote machine thats why you cannot use a restore or attach database function.
Solution:
For me the best thing to do is generate a script that will include the schema and the data of the database. This will serve as a script backup of your local database which can be run to any sql servers that you wanted. Sql Server 2008 already have the interface for this but for Sql Server 2005 you will need to have Sql Publishing Wizard.
You can download it from here: (remove spaces)
http: //www.codeplex.com/sqlhost/Wiki /View.aspx?title=Database%20Publishing%20Wizard
To create a script you can do this:
Command to run which will create schema and database:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql”
Command to run which will create schema:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -schemaonly
Command to run which will create data:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -dataonly
For more details please read...(Remove Spaces)
http: //blog.sqlauthority.com/2007/11/16/ sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/
This worked for me a lot of times.
You will need access to the file system of the database server.
You have to detach the database from your local server and then copy the related .mdf and .ldf files to the target database server and then attach the files in the SQL server management studio of that database server.
Are there any way to restore db from one server to another, if I know other server IP address?
Can I do it by sql-script or some wizard?
I use MS Sql Server Managment Studio 2008
TSQL script as
USE DATABASE -- TO TAKE BACKUP
GO
BACKUP DATABASE XXX -- XXX is database backup name
TO DISK = '\\\YYYY\XXX.BAK' -- YYYY is the shared folder to your backup and restore. Servers need access permissions on the folder as shared to available for both servers.
GO
USE MASTER
RESTORE DATABASE XXX
FROM DISK = '\\\YYYY\XXX.BAK'
GO
thanks
prav
As far as I know, you must do this in a two step process: create a backup file from the source database server, use the backup file to restore onto the target server. You can script the backup and restore presuming that one server can talk to the other, the destination server could (assuming the appropriate permissions), fire off a backup to an accessible location and then restore from that file.
you can restore your database from one server to another server by executing below script
RESTORE DATABASE mydb
FROM DISK='d:\mydb.bak'
WITH
MOVE 'mydb' TO 'D:\TSQL\mydb.mdf',
MOVE 'mydb_log' TO 'D:\TSQL\mydb_log.ldf'
I am getting following error.
Restore failed for Server
I have recently upgraded SQL Server 2005 Express to SQL Server 2008 Express.
I have taken a Backup on Production Server, having SQL Server 2008
Backup was good and I tried restoring Backup on Production Server, that works great.
Than I downloaded that backup file in .Zip format with FileZila Software (And that is good too).
But when I tried to restore that file I am getting following error.
Restore failed for Server
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------ ADDITIONAL INFORMATION:
The media family on device 'C:\go4sharepoint_1384_8481.bak' is incorrectly formed. SQL Server cannot process this media family. RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4053&EvtSrc=MSSQLServer&EvtID=3241&LinkId=20476
Things I tried which didn't worked
Attempt 1
Try to take backup using following command
BACKUP DATABASE go4sharepoint_1384_8481
TO DISK='C:\HostingSpaces\dbname_jun14_2010_new.bak' with FORMAT
And tried restore that file.
Attempt 2
Somebody wrote to test Version of my SQL Server.
When I tried to run following command in SQL Server 2008
Select ##Version
It is giving following output
Microsoft SQL Server 2005 - 9.00.4053.00 (Intel X86) May 26 2009 14:24:20 Copyright (c) 1988-2005 Microsoft Corporation Express Edition on Windows NT 6.0 (Build 6002: Service Pack 2)
My Production Database is in SQL Server 2008, and I am trying to restore DB in SQL Server 2008 but above version is showing as if i am using SQL Server 2005.
Any idea how can I restore SQL Server 2008 DB.
Many Thanks.
Is it possible that, instead of upgrading your 2005 instance to 2008, you instead installed 2008 side-by-side with 2005, and you're connecting to your existing 2005 instance? Look for other instances on your machine.
You cannot restore a backup from a higher SQL Server version on a lower version - this has never been able in SQL Server.
If you have a SQL Server 2008 backup, you can only restore that on a SQL Server 2008 (or later) machine - but not on a 2005 box. No trick, no workaround, no way to do it.
You have 2 options here.
Use WITH REPLACE while using the RESTORE command. This will overwrite the existing database and restore the database state represented by the backup files.
Delete the database to which you are trying to restore to and restore again using RESTORE command. This will create a new database with the state represented by the backup files.
Please note that in both these options you will lose the existing data of the database you are trying to restore to.
Make sure it is installed correctly - in your program files\microsoft sql server directory there whould be a 100/150 folder. Check out the install log in setup bootstrap\log.
As described above the reason for this behaviour is that by default SQL Server doesn't allow restoring a database backup to an older version of SQL Server, regardless of the compatibility level of the database the backup was taken from.
You can try to:
Start SQL Server Management Studio and connect to the instance where the database resides
In the database context menu navigate to Tasks | Generate Scripts…. This will invoke the Generate and Publish Scripts wizard
In the Introduction step of the wizard click Next
In the Choose Objects step of the wizard make sure that the Script entire database and all database objects option is selected and click Next
In the Set Scripting options step of the wizard:
Select the Save scripts to a specific location option
Specify whether the database objects and data will be scripted to a single file multiple files, as well as the path and encoding of the generated scripts
Click Advanced
In the Advanced Scripting Options dialog that will appear:
Specify the version of the SQL Server you need the database restored to in the Script for Server Version option
In the Script for Server Version option specify Schema and data
Set the following options to True:
Script Logins
Script Full-Text Indexes
Script Triggers
Click OK
Click Next
In the Summary step of the wizard click Next
In the Save or Publish Scripts step of the wizard click Finish
Execute the generated SQL script(s) against the older SQL instance
Although the procedure listed above should work:
1. It doesn’t migrate all of the database objects (e.g. sequences or queues)
2. It might fail if your database contains dependencies which SQL Server fails to recognize (e.g. dependencies to databases residing on linked servers)
You can take a look at the rest of the article on Solution center. There is also third party tools you can take in consideration.