Download an entire SQL Azure database as single file - azure-sql-database

Is there a facility in Azure to get a copy of the database? Or rather, detach the mdf and get it as file? On occasion I create a database in the cloud, it's up for a while, and then I want to take it down and archive it. My current rutine copies the database using SQL Azure Migration Wizard to a local Express instance, which I then detach and put in a safe place.
EDIT
Interestingly my method of choice throws an exception this time around. So it's far from ideal.

There is another way to do it:
"C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /Action:Export /SourceServerName:"tcp:xxxxx.database.windows.net,1433" /SourceDatabaseName:DbName /SourceUser:user /SourcePassword:password /TargetFile:C:\backups\backup.bacpac

From SQL Server Management Studio 2014, connect to the destination database server, right click its Databases node, and click Import Data-tier Application. In the import wizard, select the option to import from Windows Azure.

Using Sql Managment Studio (I use 2012):
Create a new local database.
Right-click in the database -> Tasks -> Import Data
Then you need to select the azure database as the data source and you new local database as data destination.
At this point, you can create a sql server backup or generate a sql script file to get a local copy at that moment.

I created the Enzo Backup for SQL Azure utility for that very reason. You can create a full backup and get your hands on a file that you can restore later to either another SQL Azure database, or a SQL Server database.
Note that SQL Azure will offer a form of backup, cloud-only, in the future. That's another good option. Finally Red-Gate has a product to copy a SQL Azure database to a local SQL Server database, but I am not sure that it gives you a "backup file" per say.

There is a RedGate tool that will backup your database to a local server http://www.red-gate.com/products/dba/sql-azure-backup/
I have found this useful before I do any database upgrades, in case bad stuff happens.

Since I've asked this question, the Azure management console added an option to export the entire database to blob storage. You can keep your backups there, but if you prefer a hardcopy there are many blob explorer tools such as this one.

A good free option I've been using for past few years is Sql Backup and Ftp. It's 100% free if you backup to your local laptop.
External storage requires paid license though.
From the website:
No more multi-step SSMS configuration, just a single form to automate backups: select databases, backup (full, diff, tran log), encrypt, compress, send to a folder, FTP or cloud service:
schedule backups, receive confirmation emails and restore when needed.

Related

MSSQL database on external hard drive shows Recovery Pending

I have created a database in SQL Server 2012 with mdf and ldf pointing to a external hard drive attached to my machine. I created tables, stored procedures, populated tables, etc. etc.
I removed the hard drive at the end of the day.
Today, when I attached the hard drive and tried to access the DB in Management Studio, I see the name of the database with (Recovery Pending).
What does this mean? I see the mdf and ldf files in the D drive.
What worked for me was to take the database offline*, then back online - no RESTORE DATABASE was necessary in this case, so far as I can tell.
In SQL Server Management Studio:
right-click on the database
select Tasks / Take Offline ... breathe deeply, cross fingers...
right-click on the database again
select Tasks / Take Online
When you removed the drive, you forcefully disconnected the database from the SQL Server service. SQL Server does not like that.
SQL Server is designed by default so that any database created is automatically kept open until either the computer shuts down, or the SQL Server service is stopped. Prior to removing the drive, you should have "Detached" the database, or stopped the SQL Server service.
You "may" be able to get the database running by executing the following command in a query window: RESTORE DATABASE [xxx] WITH RECOVERY;
You could, although I would not normally recommend this, alter the database to automatically close after there are no active connections.
To accomplish this, you would execute the following query:
ALTER DATABASE [xxx] SET AUTO_CLOSE ON WITH NO_WAIT;
Another way that works is to "Restart" the Database Engine. If feasible and/or practical for this server, it may be faster whenever you have several DB in the external drive.
In SQL Server Management Studio:
Attach the external drive
right-click on the database engine : Server Name(SQL Server
12.0.2000 ... etc)
Select "Restart"
Answer Yes when asked if you want to proceed
Below worked for me:
Run SQL Management Studio as Administrator (right click on SQL
Management Studio icon and select 'Run As')
Take database offline
Detach the database using DROP option
Attach the database
If you were using this database with a Web App running on IIS then you may need to restart the IIS Server
Hope this helps someone
If the SQL Server knows that database recovery needs to be run but something is preventing it from starting, the Server marks the db in ‘Recovery Pending’ state. This is different from the SUSPECT state because it cannot be said that recovery is going to fail – it just hasn’t started yet.
Check this thread: How to fix Recovery Pending State in SQL Server Database?

How can I move data from one SQL Server to other?

I want to copy all my database to remote database server. I have access to server using SQL server management studio.
How can I do this? I have created script with data of old database and tried to run it on new server but it is taking too much time and returns different errors like duplicate key etc.
If this is a one time deal, you should download Redgate's SQL tools. They can handle this easily and are free to test for 14 days I believe. (http://www.red-gate.com) You might even find they are worth the purchase as I have. The tools you would use are SQL Compare (to copy structure) and SQL DAta Compare to actually copy the data.
Assuming that you can restore databases to your remote SQL server, you can use SQL Server backup and restore? They're available in SQL Server Management Studio. See http://msdn.microsoft.com/en-us/library/ms187510.aspx. It's very easy to use.
Other than that, you can try copying the database MDF and LDF files from your local database onto your remote database filesystem, then attaching to the MDF file on your remote database.
Those are probably the fastest ways that you can copy and entire database to a remote location that I can think of.
Try Database publishing wizard by Microsoft. Good enough for no very big data amounts.

How to setup database in SQL Server by an unknown file?

Probably this is the lamest question ><
I am developing an ASP.net web app with SQL Server database. When the client asked me to develop the system, he provided a file for the database.
I thought the file was a dumpfile (if you familiar with oracle or mysql, you can replicate database with dumpfile, which is basically bunch of queries inside a text file).
To my horror, plus with my noobity in SQL Server, I found out that it was NOT a dumpfile. The file is rename to .bak which is not really the correct extension for SQL Server. I tried to rename it to .mdf, but no luck.
What should I do? The client is out for vacation on some island and cannot be contacted at the moment?
This is backup file, you need to restore database from backup.
How to: Restore a Database Backup (SQL Server Management Studio)
This is SQL Server backup database file. You can restore it by following these steps: http://msdn.microsoft.com/en-us/library/ms177429.aspx
Alex Aza has the right answer. But remember to create users for the database, before you restore the provided .bak file. A backup file only hold a user id -- the complete user definition is held in the server instance. Thus, it is better to create the users needed before restoring a backup from another server instance which is the case in your project.

SQL 2005 Moving from Godaddy SQL Server to a company owned server

What is the best way to go about moving a database from a Godaddy SQL 2005 account to a local SQL 2005 server? I have access to the DB through Server Management Studio Express and also through the Godaddy SQL explorer.
However, I have no idea where to start. In MySQL, I would just export the data through the PHPMyAdmin page, and conversely import it on the other server using an ASCII file. In access, I'd just use the migrate tool. In Server Management Studio, I've thought about using the "Backup" and "Restore" method, but I'm afraid that I won't have the ability to create a new object with the correct permission schema on the new server.
What are your thoughts? Keep in mind that I do not have access to the MDF or temp files. I've been studying this page.
SMSS should be able to do it for you. If you are looking to move the entire database and not just a few tables, the Backup and Restore method is probably your best bet.
Your steps might include:
connect to Godaddy sql server in ssms
Right click the database you want to move and select Tasks > Backup
Keep/set Backup type = "Full" and add a destination at the bottom that you will be able to access.
After backup completes, move the .bak file to a location that your local sql server can see.
Connect to your local sql server in ssms.
Right click Databases > Restore Database
Enter the database name you want in "To Database:"
Select "From device:" and locate the .bak file you created before.
In the row that shows up in the grid display, check the restore check box.
If it matters to you where the recreated files will be stored, select options on the top left menu and confirm the file locations under the "Restore As" column in the data grid.
Click ok and the restore should start.
To migrate users, follow the directions at http://support.microsoft.com/kb/918992
Don't be so afraid of the backup and restore. You have a much better chance at getting a high fidelity copy of your data than trying to roll your own. Give it a shot, test it out, and see what happens. I think you'll be pleasantly surprised.

How do I backup database from ServerGrid.com?

I have a hosting account with servergrid.com. I want to backup my database, they say I have to use Sql Server Integration Service to backup the database and I would need a commercial version of Sql Server management studio.
I have Sql Server 2005 Developer Edition. I have no idea how to do SSIS backup. I tried playing around with the Sql Server Integration Services Project in VS2005 .. but I failed.
Google also seems to have no step-by-step guide for Non-DBA's like me.
Can anybody point me to/write me a Step-by-Step instructions on how to backup database using SSIS? and also if possible how to restore the database again to the host
SSIS is not really a database backup tool.
If you have a fixed number of tables, you can export the data from SQL Server to comma-separated or raw files - i.e. do the data export using SSIS. It is easy to create such package using SSIS project if you have small number of tables. But if you have a lot of tables it is all manual process. Also it could be hard to automate this - every time you add/remove/change a table or a column, you have to regenerate the SSIS package used to export your data.
SSIS does only data export, so you need a separate tool to do metadata backup (table and stored proc definitions). You can export the metadata using Management Studio (simply script database to text file).
One can call these two tools together a poor man backup tool, but if you metadata changes often you'll probably want to use the real SQL backup tool. Not sure why the hosting guys say you have to use SSIS - maybe they don't want to give you backup permissions to ensure DB safety, but SSIS is not the simplest way to do database backup.
You have a local drive on this machine, correct?
Get access to the sql prompt, through their tools or sqlcmd.
BACKUP DATABASE MYDB TO DISK = 'E:\backups\mydb.bak'
Then FTP that file offsite.
Otherwise, forget these creeps that make you use SSIS to perform tasks that can be done with one line of text.