SQL Server 2012: Backup restore from a compressed backup - sql-server

I am trying to restore a database from the backup (.bak) file which is [saved] inside a ZIP file, but not been successful so far. However, I am able to restore it after extracting from the ZIP file.
This MS page says every edition of SQL Server 2008 and later can restore a compressed backup with the following restrictions.
Restrictions: The following restrictions apply to compressed backups:
Compressed and uncompressed backups cannot co-exist in a media set.
Previous versions of SQL Server cannot read compressed backups.
NTbackups cannot share a tape with compressed SQL Server backups.
I do not clearly understand the first restriction. Could someone please clarify/elaborate this?
I have done the following steps:
Taken a backup on a staging SQL Server [MyTestDB.bak]; Compressed it (by Right Click > Send To - Compressed(zipped) folder); Now, named it as MyTestDB.ZIP
FTP'd the ZIP file to local development SQL Server and trying to restore it from the ZIP file. But the database name is not available to backup.
Both SQL Server versions are exactly same.
SQL Servers Version: Microsoft SQL Server 2012 - 11.0.5058.0 (X64)-Standard Edition (64-bit)
Would the usage of term 'compressed backup' for the backup files saved inside ZIP files is correct or Is this need to be backed up in a different way so it can be called as a compressed backup?
However, if I select the .bak file after extracting it from the ZIP file it all works fine.
I am not sure where I am going wrong? I can simply extract the backup and restore it without any problem, but would like to know the cause why it is not working, as it would have been a much better solution to just back up it from the ZIP itself.

Backup compression is something different.
You specify this when you configure or start the backup and you then get a backup file that contains compressed data, as opposed to it containing uncompressed data if you don't enable compression.
SQL Server is not able to use a zip file, while the backup file is certainly compressed, it is not a "compressed backup" that this refers to.
So yes, you need to extract the backup file before restoring from it.
If you want to learn how to make compressed backups correctly, check out this page full of links to related material:
Configure Backup Compression

Related

Restore marklogic database by extracting config from backup

I have been given a copy of a Marklogic v9 database backup which was taken from a Marklogic server running on linux.
I now need to restore the database from the backup dump, onto a windows 2016 server, but the MarkLogic database on the destination windows server doesnt exist.
Is it possible to somehow extract the MarkLogic database configuration from the backup dump , create a database on the destination server then restore over that database? In the backup dump I have a forests directory and all the XML/cfg/label files in the root directory of backup dump.
Or do I need a MarkLogic admin to extract the config of prod database that was backed up, then create an empty database on the destination server ( using the extracted prod database config ), then restore over that? I notice you cant restore without an existing database to restore over.
Or do I alternatively create a dummy database on my destination server of the same name as the prod database, then restore over that? The disk layout obviously will be different.
Any help appreciated.
You cannot restore a backup from a different architecture. If you need to move from Linux to Windows, I'd recommend using MLCP export/import, or maybe even copy. In any case you will need to have a target database up and running. You could export the configuration from one system, and import it in the other using our REST apis, like Configuration Management API or Management API. Our community tool ML-Gradle could be of help with that.
HTH!

Transporting a SQL Server database dump (of data and models) from one environment to another using Microsoft SQL Server Management Studio

Surprisingly, I did not find a concise way on Stackoverflow or elsewhere, so please allow me to ask.
I want transport a complete SQL Server database from one environment to another using the Microsoft SQL Server Management Studio (SSMS).
I guess I need a complete database dump (of model and data) e.g. from the production environment, which I then restore e.g. on the pre-production environment.
I am more the MongoDB guy, and it is straight forward there. But how do I quickly backup, transfer and restore a complete T-SQL database (context) using SSMS? The issue is that I should explain somebody else what to do since I do not have the rights to try it myself.
The official documentation on backup and restore is rather lengthy, but I get the concept, I hope. Except for the copy only backup, maybe. The definition reads:
Copy-only full backups (all recovery models)
A copy-only backup cannot serve as a differential base or differential backup and does not affect the differential base. Restoring a copy-only full backup is the same as restoring any other full backup.
Do I need a copy-only backup for my purpose? If so, why?
Recipe Draft
Within SSMS on the source server, open the Object Explorer (F8), right click on the DB you want to transport (e.g.myDB) and choose Tasks > Backup...
In the pop-up window, choose Backup Type: Full. Under Destination, choose Back up to: Disk and add a folder.
Navigate to the folder where the .bak file is stored, e.g. C:\Program Files\Microsoft SQL Server\MSSQL 14.MSSQLSERVER\MSSQL\Backups\, transfer it to the destination server onto a similar location.
On the destination server, open the Object Explorer (F8). Make sure you have no database context called myDB, then right click on another context, choose Task > Restore > Database... and then what?
I would also need help with the last step, please. The popup window shows on top No backup set selected to be restored. and keeps freezing if I want to choose the myDB.bak file.
References
SQL Server Management Studio: Backup and restore database without data
Import / Export database with SQL Server Server Management Studio - loads of hits, but rather old and not quite fool-proof recipes
Copy database from SQL server management to another instance Directely
Microsoft SQL DB to MySQL DB
restore sql backup with microsoft management studio
You should use COPY_ONLY if you don't want to mess with the potentially existing backup set. For example, if you have some backup solution that takes differential backups (log backups) in between full backups. You need to use COPY_ONLY if you're manually going to take a FULL backup, otherwise you will make the differential backups useless until the next FULL backup is performed by your backup solution (or you have to use that FULL backup of yours together with the diff backups in case of a point-in-time restore, but you risk having issues using that with your normal backup solution).

Fastest Way to copy/transfer Tera bytes of data between SQL Database Servers

I am looking for a most efficient and fastest way to transfer huge data from a SQL Server located in Europe to SQL Server located in USA.
The traditional ways are taking longer time.
Linked Server
SQL bulk copy or BCP
SQL database replication
SQL Import Wizard
Cloud is an option but it comes with data privacy issues. I am not looking for offline copy using backup and restore or transfer via hard disc.
Can anyone suggest the best way to overcome this issue ?
You can ask the company from Europe to back everything up in a HD and ship it securely. My work does it this way. Shipping Oracle DB copies from LA
Alternative 1: using compressed full backup file of the database
Full backup the database
Compress the backup file and splitting it into smaller chunks of size 500MB (or less) using zip tool.
note: You can back up to multiple files with compression that save about 60%– in one or more locations using SSMS or T-Sql script – and multiple threads will be used.
This can make a backup take less time and no need to use zip tool.
Host the files in ftp server or http uploader server
Copy the data files from the source http/ftp using http /ftp protocol
In the target server uncompress the files and compose one backup file
Restore the database
Update:
Alternative 2: Using compressed bcp files
SQL bulk copy or BCP out as native data
compress the files using zip
host files in ftp server or http uploader server
Copy files from the source http/ftp using http /ftp protocol
in the target server uncompress the files
bcp in from data files
note:
You can use batch file or Powershell scripts to automate these tasks
Speed of network is controlled by network speed of the service provider, contact your internet service provider to get the max speed.
We avoided the online interaction between source/target Sql servers to avoid the time out of the network.

Restore a SQL Express database from a file backup

I'm using a SQL Express database on my development machine. Unfortunately, I had to re-install the operating system and all the software on the machine. Now I need help to restoring the database that I was using before the re-installation. I have a backup of all files on the computer from before re-installing, but how do I find and restore the database from it?
You say you have a backup, but I'm not convinced that you do. Do you have any *.BAK files on your machine?
If not, you need to locate the data file (and preferably the log file as well). Depending on how you created the database originally, the files /should/ be in the form of <database name>[_data].mdf (data file) and <database name>[_log].ldf (log file).
Once you've found the files, you can use CREATE DATABASE ... FOR ATTACH and if the log file is damaged you can use the option FOR ATTACH_REBUILD_LOG instead.
A couple of notes:
(a) if you have a backup of the database, the link Rick Liddle created will be useful. Depending on whether your new instance of SQLExpress is located in the same location, you may need to use WITH MOVE to move the data and/or log file to valid folders in order to restore your databases.
(b) depending on what happened to your old machine (e.g. did it crash and die, how was the backup obtained, etc.), the mdf and/or ldf files may not be restorable. This is what proper database backups are designed to insure against.
Are you sure you have an actual backup (.BAK)?
Create a new database.
Right click
Select Tasks
Restore
Files and FileGroups...
Select File

how to restore a sql server backup whose file is on another machine?

How is it possible to restore a database in Machine A (where sql server is installed) from the backup file located in Machine B.
Is it possible to avoid to copy the bak file to the machine A?
Yes it is.
Create a file share on machine B. Then restore from the file there.
Although you don't create a copy of the file 'per se' you still have to get the content of the backup file across.
You have to (read: want to) get that file on the server hosting SQL Server. Assuming that this is a large file, you don't want to restore from across the network which will be much slower. If you can't copy it because of the time involved, or the space on the SQL Server, I'd suggest an external USB drive or something.

Resources