[sql] How can I backup a remote SQL Server database to a local drive?

I need to copy a database from a remote server to a local one. I tried to use SQL Server Management Studio, but it only backs up to a drive on the remote server.

Some points:

  • I do not have access to the remote server in a way that I could copy files;
  • I do not have access to setup a UNC path to my server;

Any ideas of how can I copy this database? Will I have to use 3rd party tools?

This question is related to sql sql-server backup

The answer is


I'm astonished that no-one has mentioned the scripted backup solution offered by Ola Hallengren which absolutely does allow you to backup a DB from a remote server to a UNC path on your network for free (I'm actually using it as I type to backup a DB from a dev server to which I have no remote access other than through SSMS to a share on my dev PC). This has been available since 2008 and works on SQL Server 2005 through to 2014.

You need to ensure that the share you set up has enough access: I tend to allow full read/write to the 'Everyone' AD group for the duration of the backup process because I'm too lazy to figure out anything more restrictive but that's personal choice.

It's well-used, well-documented and very flexible. I tend to put the procs and the logging table in their own little utility database and then fire it up. Provided everything is in your AD domain and not remote in the sense that it's out on a co-located server or something, this works very well.

Apologies for adding to a very old thread but I came across this when looking for something else and figured it was a worthwhile addition for anyone looking for this topic.


yone way you could take a backup from a remote SQL Server instance to your local drive, given the following condition is met:

  1. You have a shared folder on your local drive.
  2. the shared folder is accessible from the SQL Server box.

Now when specifying the backup command, use the shared folder path when specifying the disk option.


For 2019, I would recommend using mssql-scripter if you want an actual local backup. Yes it's scripts but you can adjust it to include whatever you want, which can include all of the data. I wrote a bash script to do automated daily backups using this on a linux machine. Checkout my gist:

https://gist.github.com/tjmoses/45ee6b3046be280c9daa23b0f610f407

You can use Copy database ... right click on the remote database ... select tasks and use copy database ... it will asks you about source server and destination server . that your source is the remote and destination is your local instance of sql server.

it's that easy


I know this is an older post, but for what it's worth, I've found that the "simplest" solution is to just right-click on the database, and select "Tasks" -> "Export Data-tier Application". It's possible that this option is only available because the server is hosted on Azure (from what I remember working with Azure in the past, the .bacpac format was quite common there).

Once that's done, you can right-click on your local server "Databases" list, and use the "Import Data-tier Application" to get the data to your local machine using the .bacpac file.

Just bear in mind the export could take a long time. Took roughly two hours for mine to finish exporting. Import part is much faster, though.


You can try SQLBackupAndFTP. It will create scripts to create all the objects in your database and INSERT statements for all the rows in your tables. In any database you can run this script file and the entire database will be re-created.


There is the 99% solution to get bak file from remote sql server to your local pc. I described it there in my post http://www.ok.unsode.com/post/2015/06/27/remote-sql-backup-to-local-pc

In general it will look like this:

  • execute sql script to generate bak files

  • execute sql script to insert each bak file into temp table with varbinary field type and select this row and download data

  • repeat prev. step as many time as you have bak files

  • execute sql script to remove all temporary resources

that's it, you have your bak files on your local pc.


I use Redgate backup pro 7 tools for this purpose. you can create mirror from backup file in create tile on other location. and can copy backup file after create on network and on host storage automatically.


Create a local shared folder, with "everyone" read/write privileges

Connect to the target database, start the backup and point to the share like below

\mymachine\shared_folder\mybackup.bak

(Tried on Windows domain environment)


If you use the Generate Scripts under SSMS, click the Advanced button. Under the 'Generate Scripts for the dependent objects' option, click True. By clicking that any dependencies of each object will also be scripted out in proper order.


First, grant full control permissions to a local path on your machine (as shown below) with Everyone. (Or alternatively grant permissions specifically to the SQL Server Agent account).

Second, execute the following:

BACKUP DATABASE [dev] TO  DISK = N'\\myMachine\c\dev.bak' WITH COPY_ONLY, INIT;

You cannot create a backup from a remote server to a local disk - there is just no way to do this. And there are no third-party tools to do this either, as far as I know.

All you can do is create a backup on the remote server machine, and have someone zip it up and send it to you.


Look at this blog for a description how to copy a remote database:

Backup a SQL Server 2008 Database From a Shared Hosting Environment


To copy data and schema only (will not copy stored procedures, functions etc.), use the SQL Server Import and Export Wizard, and choose New... when choosing the destination database.

Right Click Database > Tasks > Import Data.

Choose a Data Source

  • Data Source: SQL Server Native Client
  • Server Name: the remote server
  • Authentication:
  • Database: the db name

Choose a Destination

  • Data Source: SQL Server Native Client
  • Server Name: the local server
  • Authentication:
  • Database: New...

The rest is straight forward.


As Martin Smith said, if you have no access to the machine or the filesystem, you will need to use third party tools, like Red Gate or Adept to do a compare on the source and destination systems. Red Gate's tools will allow you to copy the objects and schemas AND the data.


I know this is late answer but I have to make a comment about most voted answer that says to use generate scripts option in SSMS.

Problem with that is this option doesn’t necessarily generate script in correct execution order because it doesn't take dependencies into account.

For small databases this is not an issue but for larger ones it certainly is because it requires to manually re-order that script. Try that on 500 object database ;)

Unfortunately in this case the only solution are third party tools.

I successfully used comparison tools from ApexSQL (Diff and Data Diff) for similar tasks but you can’t go wrong with any other already mentioned here, especially Red Gate.


The AppHarbor gang has been struggling with this and has developed a temporary solution using SQL server management objects and SqlBulkCopy.

Check out their blog post about it, or go straight to the code.

They've only tested it with AppHarbor but it may be worth checking out.


If you are in a local network you can share a folder on your local machine and use it as destination folder for the backup.

Example:

  • Local folder:

    C:\MySharedFolder -> URL: \\MyMachine\MySharedFolder

  • Remote SQL Server:

    Select your database -> Tasks -> Back Up -> Destination -> Add -> Apply '\\MyMachine\MySharedFolder\BACKUP_NAME.bak'


The answers above are just not correct. A SQL Script even with data is not a backup. A backup is a BAK file that contains the full database in its current structure including indizes.

Of course a BAK file containg the full backup with all data and indizes from a remote SQL Server database can be retrieved on a local system.

This can be done with commercial software, to directly save a backup BAK file to your local machine, for example This one will directly create a backup from a remote SQL db on your local machine.


I could do that once...TO do this you have to have a share opened on the remote server. then you can directly place the backup on the share itself, than the default location...

Usually the admin takes the backup and shares it with us in some shared folder. I tried if that will work if i place the backup there. It worked.


Some third-party backup programs allow setting file transferring with specific network permissions. It it very useful when SQL Server service is running under restricted account and does not have enough network permissions. Try using EMS SQL Backup which solves this task.


just try this one:

1)Share a folder with full permission in your computer

2) in your SQL server : control panel -> administrative tools -> services -> right click on all SQL services

on log on tab should start with your domain administrator

3) in maintenance wizard of sql server place the back up location and folder (\yourcomputername\sharedfoldernam)

I did remote backup on 8 server of sql server 2008 in our company


Examples related to sql

Passing multiple values for same variable in stored procedure SQL permissions for roles Generic XSLT Search and Replace template Access And/Or exclusions Pyspark: Filter dataframe based on multiple conditions Subtracting 1 day from a timestamp date PYODBC--Data source name not found and no default driver specified select rows in sql with latest date for each ID repeated multiple times ALTER TABLE DROP COLUMN failed because one or more objects access this column Create Local SQL Server database

Examples related to sql-server

Passing multiple values for same variable in stored procedure SQL permissions for roles Count the Number of Tables in a SQL Server Database Visual Studio 2017 does not have Business Intelligence Integration Services/Projects ALTER TABLE DROP COLUMN failed because one or more objects access this column Create Local SQL Server database How to create temp table using Create statement in SQL Server? SQL Query Where Date = Today Minus 7 Days How do I pass a list as a parameter in a stored procedure? SQL Server date format yyyymmdd

Examples related to backup

input file appears to be a text format dump. Please use psql How can I backup a Docker-container with its data-volumes? Backup/Restore a dockerized PostgreSQL database Export MySQL database using PHP only Tar a directory, but don't store full absolute paths in the archive How to extract or unpack an .ab file (Android Backup file) mysqldump with create database line Postgresql 9.2 pg_dump version mismatch How to backup Sql Database Programmatically in C# Opening a SQL Server .bak file (Not restoring!)