I have a script that download an SQL Server backup from SAAS product every night.
I can't change the original database and I created 2 views on the database.
Is there a way to keep the views that I created while restoring a new version of the DB?
Related
I maintain a SQL Server 2017 database server with production (PROD) and reporting (REPORT) databases. The databases have similar structure, but the time span of the production database is 3 years and the archive database contains all data since the beginning of the system delivery.
We want to set up replication from PROD to REPORT so that any new changes to PROD get replicated to REPORT. However, when my colleague set up replication, the REPORT db gets truncated and rebuilt so that it becomes a copy of PROD. Are there any configuration that we are missing to maintain REPORT so that it contains all data including the updates?
I'm setting up an Azure SQL DB for our Web App. We have enabled Point In Time Retention (PITR) and Long Term Retention (LTR). Our process is to keep backups for 1 year.
Periodically, we need to upgrade the DB by applying SQL scripts. Sometimes there is a problem with the upgrade scripts and the upgrade fails. We need to rollback the database to the previous version.
To rollback the DB I tried the restore feature. However, the restore feature seems to only create new DBs; therein lies the problem. Restoring to a new DB and removing the old one works great, but we lose all our backup history. It appears backups are tied to the DB (probably to the ResourceId).
So, how can I use Azure SQL DB and periodically restore a DB and still maintain all the back up history?
Unfortunately, restoring from a backup in Azure SQL Database always creates a new database. The secret here may be to rename the newly restored database with the name of the original database. You will even see that the restored database once renamed it then shows all the security recommendations, automatic tuning recommendations of the original database.
So delete existing database, restored the database, and rename it as the original database.
You can reference this document Recover an Azure SQL database using automated database backups , it gives the answer that all the recover are creating new database.
By default, SQL Database backups are stored in geo-replicated blob storage (RA-GRS). The following options are available for database recovery using automated database backups:
Create a new database on the same SQL Database server recovered to a specified point in time within the retention period.
Create a database on the same SQL Database server recovered to the
deletion time for a deleted database.
Create a new database on any SQL Database server in the same region
recovered to the point of the most recent backups.
Create a new database on any SQL Database server in any other region
recovered to the point of the most recent replicated backups.
If you configured backup long-term retention, you can also create a new database from any LTR backup on any SQL Database server.
improtant:
You cannot overwrite an existing database during restore.
"So, how can I use Azure SQL DB and periodically restore a DB and still maintain all the back up history?"
You can use Database replacement:
If the restored database is intended as a replacement for the original database, you should specify the original database's compute size and service tier. You can then rename the original database and give the restored database the original name using the ALTER DATABASE command in T-SQL.
Hope this helps.
I am really really new to SQL Server, I know how to do a query and other simple stuff and recently my company was bought by another one, we had a Cube Server which was accessed by a excel file via olap using the analysis services from sql server 2008 it was updated by an .abf file, first day after the sale the former server was retired, and everything I have access to is this .abf file used to update the cube, I installed sql server 2008 enterprise edition and I'm trying to restore the file to a new database via the analysis services since the only instructions I received from the old IT department is that is needed to be restored via analysis services. I searched online for some solutions and came across several articles and none of the steps worked for me because they required a already configured database and they were only restoring a backup. I'm thinking I need the .mdf file first so I can recreate the database as is and then I can update it via the .abf file, can someone point me in the right direction?
Since you have the .ABF file, there are a couple options to restore this as a new database. You can either create a new database with the same name, then restore this database from the .ABF file with the AllowOverwrite option set to true. You can also restore directly to a new database by right-clicking the SSAS instance and selecting Restore... From here, specify the backup file name and just enter the name of the database and this will be created as a new cube. This name must be a new database name, as if an existing cube is specified it will be overwritten. Either approach can be done through an XMLA command in SSMS and an example of this is below.
<Restore xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<File>C:\YourFilePath\YourCubeBackupFile.abf</File>
<DatabaseName>TargetOrNewDatabaseName</DatabaseName>
<AllowOverwrite>true</AllowOverwrite>
</Restore>
Try attaching the database with the mdf file in the sql server 2008.
I want to copy production server database to Development server, I am using backup and restore to take production server db to Development server.
I have restored it successfully and added tables and SP in restored DB.
Again next day I have to restore same database, after restore my existing tables and SP will get deleted.
I can not use SP and extra tables on production server DB. I want to copy it to development server with a real time data and on development server I can do anything without impacting to production server db.
Can anyone suggest better way to doing this?
You are saying you want to merge changes.
Use a database diff tool (such as database compare in visual studio 2013 to generate a 'difference' script between your dev and prod database. For example you run this tool against dev and prod and it spits out a bunch of create procedure, view, table etc. scripts
Generate insert scripts for all dev - only tables
Restore prod over dev
Execute the scripts from step 1 and 2 in dev
There is often some human intervention required in any kind of merge. For example what if your prod tables have a column that is a different data type in dev, and your SP's are expecting this?
The other option is to build integrations that just load data from prod into dev, but this requires maintenance as changes occur in dev and prod
Yes, you should take a incremental backup rather than a full backup, since a full backup has already been restored to your Dev database. Then while you re-store it should get the newly created DB objects or data.
I am a newbie to SQL DBA, I wanted to understand the following concepts
What is the difference between a Database migration & Database Refresh in SQL?
Suppose we want to migrate a database from one instance to other instance, can we follow the below method
Create a new DB in the destination instance with the same name as the source instance
Refresh destination DB with Source DB, & copy all the user access
Database migration:
Moving a database from one server to other usually will do for database upgrades.
Database Refresh in SQL:
Overwrite the existing data in the database with other database data using backup files. Usually will refresh production data to UAT or DEV for data/Issue analysis.
Suppose we want to migrate a database from one instance to other instance, can we follow the below method?
Yes you can follow.
If you are using sql server 2012 and above then you can go for contained database options.