I have a test.bak
file in my local machine. I need to restore this file to remote machine's database. How do I do that?
When I try this, the remote database throws an error that it is not able to find test.bak
on the local filesystem.
Query
RESTORE DATABASE TESTPROJECT
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ICON3\MSSQL\Backup\test.bak'
Error
Cannot open backup device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.ICON3\MSSQL\Backup\test.bak'. Operating system error 2(The system cannot find the file specified.).
How can I achieve this? I am using Microsoft SQL Server 2008.
Restore the database from a BAK fileRight-click on the database server in the left navigation pane, click Tasks, click Restore. The name of the restoring database appears in the To database list box. To create a new database, enter its name in the list box. Select 'From device'.
Connect to the appropriate instance of the SQL Server Database Engine, and then in Object Explorer, select the server name to expand the server tree. Right-click Databases, and then select Restore Database. The Restore Database dialog box opens. Select the database to restore from the drop-down list.
In the above method to restore database in sql server is to restore database from bak file using script, so suppose here we have .bak file in D:\, we can run script as below Connect to the Database Engine. From the Standard bar, click New Query. In the RESTORE statement, specify a logical or physical backup device to use for the backup operation.
Show activity on this post. In the context of this answer - remote refers to your machine, local is the database server. Copy the backup file to the local filesystem, and restore directly from this copy. Alternatively you can restore from the remote backup file using UNC syntax.
In the prompt window General page Source section, select Device > … >Add, to specify the location and select the backup file you want to restore. The name will be filled automatically in the blank of Database. Then click OK. 3 . When you restore SQL backup to the same server, the operations next will be different from restoring to another server.
1 From ‘Select backup devices’ window, choose File as backup media, and then click Add. 2 Locate and select the .BAK file you want to restore, and then click OK. 3 Again click OK to return to the Restore Database window.
In the context of this answer - remote
refers to your machine, local
is the database server.
Restore from local
filesystem
Copy the backup file to the local
filesystem, and restore directly from this copy.
Prerequisites
test.bak
to C:\test.bak
on the serverSyntax
RESTORE DATABASE TESTPROJECT FROM DISK = N'C:\test.bak';
Restore from remote
filesystem
Alternatively you can restore from the remote
backup file using UNC syntax. I typically don't use this option, but it is useful if there won't be enough disk space on local
filesystem for both the backup file and the restored database.
The success of this option depends on some variables - permissions on the remote
filesystem assigned to the database service account, network health, and others.
Prerequisites
Remote
machine name is remotemachine
remote
at 'C:\test.bak'
remote
administrator share C$
Syntax
RESTORE DATABASE TESTPROJECT FROM DISK = N'\\remotemachine\c$\test.bak';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With