I know Azure does automatic backup and restoring based off those automatic backups. I need to create a manual backup of a database. From reading online, I created a bacpac file using Export and saved to an Azure Blob (how to here). The problem is when I go to 'Restore' using the Azure Portal, it only gives me the option to choose one of their automated backups.
On top of this, I would actually like to restore that database to another database (think restoring Production to Test). I cannot do this either.
I believe they used to have an Import + Export function when in the portal. Now it is Restore and Export, I'm wondering if they somehow took this capability away, I'm not sure.
I know I can create a new database from a .bacpac file, but this does not help me in any way shape or form.
There is a copy command you can execute from the old portal. Select a DB from the list and a copy toolbar item appears.
Related
Is it possible to copy a database to a new server? I just want to have the database on a new server because I need to make some tests. I didn't have much experience with servers.
Follow this steps :
Run your SSMS
Right click on the database you want to copy
In the Popup menu , go to Taches , then click Offline
Right click on the Database again in the popup menu , Taches -> Detach
Open the folder ..\MSSQL\DATA , copy Yourdb.MDF and YourDB_log.LDF files to the folder of the new Instance.
Now you can Attach both Databases and work on it in both instance.
Another way:
Run Your SSMS
Right click on the Database you want to copy
In the popup menu , Taches -> Copy the database...
Follow the steps on the Wizard
You can select option if you want to keep the database ONLINE when it is being copied.
You can also select option of MOVE or COPY database as well.
When the process is over it will show the success message and database will be copied to another server.
Note:
1- The Copy Database Wizard is not available in the Express edition.
2- The Copy Database Wizard cannot be used to copy or move databases that are/have:
System.
marked for replication.
marked Inaccessible, Loading, Offline, Recovering, Suspect, or in Emergency Mode.
data or log files stored in Microsoft Azure storage.
Also , a database cannot be moved or copied to an earlier version of SQL Server.
Updtae:
If there is no Copy database option , then you can Copy Databases with Backup and Restore.
For more information about it MSDN.
No experience? No problem, backup the database.
Copy it into the target machine.
Restore DB from device >> open the DB backup file.
At this point you have the entire DB without missing any schema objects such as foreign keys.
Finally delete all sql logins that the DB came with and recreate them manually as you test access.
Once you are comfortable with this operation you can go ahead and get more experience using some of the techniques describe above which are recommended if you have a large DB to restore and so on.
How to restore the DB on SQL Server Management Studio
Steps:
1. On “Object Explorer” panel right-click on “Databases” and selected Restore Database
Select “Device” and browse database location.
note: Copy the .bak file locally before restoring.
The DB information will auto-populate the window, you can edit the name of the DB to be restored.
Go to the “Files” page and check the “Relocated all files…” box.
Select existing folder locations for Data and Log files.
HIT OK
A friend of mine has 3 small SQL databases on her Azure account that she asked me to download for her. I said no problem…thinking she had a VM running with SQL Server and I could just RDC in and grab everything…no such luck and no FTP access.
I've done an export but have no idea how to download the .bacpac file.
I've logged in through the management portal - but there's no options in there to export/download anything.
Can someone tell me the best - easiest - way to save these databases? Is there an easy way to download them? If I configure a VM in her account can access them that way? Is there a way I can transfer them over to my account?
I don't know all that much about Blob storage and container management - I've seen a few instructions and they seem very complex to me just to download a .bacpac file so I'm assuming I'm missing something.
Any help or ideas would be great!
Thank you...
Rob
Here is a solution to your problem.
Use a linked server connection between your on premise database and SQL AZURE.
http://blogs.msdn.com/b/windowsazure/archive/2012/09/19/announcing-updates-to-windows-azure-sql-database.aspx
Quick list of steps.
1 - Link to SQL Azure database.
2 - Script out objects.
http://craftydba.com/?p=4827
Check out how to manage Azure from SSMS on my blog. Half way down, right click table, script as Create.
http://blogs.msdn.com/b/sqlazure/archive/2010/05/24/10014071.aspx
How to script a whole database.
3 - Create mirror database on premise using scripts from step 2.
4 - Create linked server to AZURE database.
http://msdn.microsoft.com/en-us/library/aa560998.aspx
5 - INSERT INTO SELECT * FROM
http://technet.microsoft.com/en-us/library/ms174335.aspx
Why select * into does not work in Azure. Might work with a linked server. Never tried.
http://blogs.msdn.com/b/windowsazure/archive/2010/05/04/select-into-with-sql-azure.aspx
6 - Watch out for constraints such as primary key on identity column. You will have to enable identity insert. Other constraints, you can disable.
7 - Re-enable constraints with checking.
Again, this whole process assumes you do not have a ton of data. If you do, you might want to look into using a ETL tool such as SSIS.
You can mount the Azure Page Blob as an NTFS drive using a utility like XDrive. I'm trying to use "Azure Storage Explorer" to do the same thing but it's not allowing me access to the files inside of the VHDS file (and I think that it should). XDrive is supposed to allow for a mapped drive type feel in Windows Explorer.
Backup the databases to the secondary hard drive on the Vm's. Download, install, and configure XDrive to point to this hard drive. Grab the backups. Voila! Please note that XDrive limits read/write access to distributed enviornments so this should only be used as a tempory solution for environments not distributed (ie. load balanced) or you could cause a disruption to your production users.
XDrive: http://blog.maartenballiauw.be/post/2010/02/02/Using-Windows-Azure-Drive-%28aka-X-Drive%29.aspx
Updated:
Download "Azure Storage Explorer" from http://azurestorageexplorer.codeplex.com/
From the Azure portal, click on the db you want to export and from the dashboard tab, there's an "Export" button. This will create a bacpac file.
Choose a storage account (remember which one you chose because you will have to access it later).
For the container, create a new one called "DB Storage" or something like that. You will need to server credentials to do the export.
After the export completes, open up "Azure Storage Explorer" and add the storage account you placed the backup in. You will need the storage account name and the primary key (both can be pulled from the Azure portal). I have to use the option "HTTPS" but you may or may not.
Once the account is in the explorer, on the left pane you should see the new container you created in the earlier step. Click on it which should pull up your bacpac file in the middle pane.
Highlight the bacpac file and choose download.
It's a bit of a pain because you have to install the explorer utility but after that's done, it's really easy.
Let me know if this works.
I've not done much SQL and am still pretty new to this, so please excuse what's probably a basic question.
I've been asked to look into creating an SQL job to backup our databases, store the .baks on another machine and then to restore them to a second server. I've been doing a bit of research and playing with SSMS and have back-ed up the database to my personal machine by setting up a share and running a backup job to the share location. I'm now trying to create a new database (on the same server I back-ed up from) by restoring the .bak file (but giving the database I'm trying to create a new name and what-not) but am unable to specify restoring it from the share, like I did when backing it up/I can't find how to specify other network locations and am just browsing the server's C drive when I try to locate the file.
For now, I'm just using the built-in wizards to try and achieve this (open SSMS -> Connect to server -> right click DataBases -> Restore DataBases and then select From Device and browse to find the file).
This isn't the final process, just me trying to get to grips with how this works. As I said, the idea is to ultimately have a scheduled job to backup the DB from server1 to a .bak on, say, my personal machine and then to restore that to a DB on server2 (different network, different city) and, probably, with a series of SQL commands rather than using the wizard every time (there are a few DBs that'll, ultimately, need backing up).
My apologies for the, possibly, quite drawn out and convoluted question - essentially, all I need to know is can I/how can I restore a DB in SSMS from a .bak on a different machine?
Many thanks
You could use something like the following script. It restores a database from the filesystem, and it overwrites the existing database with the name of "MyDB", moving the files to new locations of your choice in the process.
RESTORE DATABASE
MyDB
FROM DISK = '\\MyShare\MyBackup.bak'
WITH
MOVE 'DataFile' TO 'D:\myNewDBLocation\DataFile.mdf',
MOVE 'LogFile' TO 'E:\\myNewDBLocation\LogFile.ldf'
, REPLACE
You can find out the name of the llogical files (in the above, those are called DataFile and LogFile by running the following:
RESTORE FILELISTONLY
FROM DISK = '\\MyShare\MyBackup.bak'
Additional information about various options and parameters:
RESTORE (Transact-SQL)
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.
I'm trying to rebuild a web server in a virtual pc. Installed required software and Microsoft SQL Server 2005. I've had full backups of my databases but it is not possible to restore from those backups in this new installation. By the way, backups are fine, i can restore from them on original server.
In summary, how can I copy whole database to another computer? How can I backup a database and restore is fully on another computer?
Regards,
Burak
PS: The database I'm trying to restore is called "Some_db" and it does not exist on new server. I also tried to create a new one with defaults and restore on it but that gave an error on new db. I don't know any details of the database.
You have 3 Choises:
1) Restore DB as you tried
This failed for you for some reason
Here a tutorial: http://msdn.microsoft.com/en-us/library/ms177429.aspx
2) Detach DB and Atach it to the new server
This is easy: Rightclick on the DB -> Detach.
Rightclick on the new Server -> Attach
Tutorial: http://www.databasedesign-resource.com/moving-the-database.html
3) Create Create-Scripts of the table schema and use insert into statements for the data.
For this, there are a bunch of tools, my favourit is "Redgate SQL Compare".
It creates you all nessecary scripts.
The link: http://www.red-gate.com/products/SQL_Compare/index.htm
Backup file
Copy .bak file to other server
Restore .bak file.
Works every time for me. You have to make sure the new instance of SQL is of a sufficient level to be able to host the database. You also have to recreate the users on the new server and remove and readd them to each database.
The alternative to the backup and restore approach is to detach the db, copy the mdf and ldf files over and then attach them on the new server
Or take offline, copy files, attach database, bring online..
open your current query browser window and run the query .The restore will happen automatically
BACKUP DATABASE AdventureWorks
TO DISK = 'C:\Backup\AdventureWorks.bak'
GO
for more details
This will create a .bak file after that copy the .bak to server.
restore the data base by right click on DataBase .Select restore database .Give the database name and location .And restore it .