A basic SQL Server Backup strategy / tool - sql-server

I have a SQL Server 2014 running on Windows Server 2012 R2. I want to back it up daily and store backups on some remote cloud storage for reliability. Basically, that is all of my requirements.
Is there a tool that can help with this? The easier and plainer the better.

I don't see any app providing native support for cloud backups.But you can use SQLServer 2014 to backup to cloud using SQLServer Agent
Below are steps
1.create credential
CREATE CREDENTIAL MyCredentialName
WITH IDENTITY = 'MyStorageAccountName',
SECRET = 'MyAccessKey';
2.Backup
BACKUP DATABASE MyNewDB TO
URL = N'http://myserver.blob.core.windows.net/scarybu/MyNewDB.bak'
WITH CREDENTIAL = N'MyCredentialName',
NAME = N'MyNewDB-Full Database Backup', STATS = 10;
You could also experiment by adding compression ,checksum to above syntax by looking at all options..You can see below link for more experiments and results done by Jovan Popovic :Native database backup in Azure SQL Managed Instance..You can ignore copy_only syntax in the link examples,since it is only for managed instances

Related

Multiple valid AD FS configuration databases found in remote SQL Server instance

We are attempting to join a newly configured AD FS node into the existing farm. We have tested and confirmed firewall > user access is working fine. When trying to join via the wizard we specify the existing farm server, certificate (has been imported and shows in dropdown list) and service account successfully. It fails with an error:
Multiple valid AD FS configuration databases found in remote SQL Server instance with connection string 'Data Source=REDACTED;Initial Catalog=ADFSConfigurationV3;Integrated Security=True;Min Pool Size=20'. Provide a specific database version when joining the machine.
We attempt to use the script that the wizard creates via an admin powershell and are presented with the same message. I have looked at the SQLConnectionString parameters and cannot see any that would look to specify versions from https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=netframework-4.8#remarks
On the SQL server side, there is indeed an older database named AdfsConfiguration which has not been edited since 2020-09-06 by checking tables > IdentityServerPolicy.FarmNodes > right click > select top 1000 rows and viewing the Heartbeat property value. On the newer AdfsConfigurationV3 database under the same table and object I see modified 2022-03-30 (today).
How would I go about finding the multiple configuration databases and specifying exactly which to use? Is it safe to detach the AdfsConfiguration database or is this still used/in use by ADFS even with the later 2016 V3 present in a separate database?
• As you have stated that the ADFS server to be added in the farm is running on Windows Server 2016, the FBL (Farm Behaviour Level) version is 3 and the corresponding ADFS Configuration Database Name will be ‘AdfsConfigurationV3’. Thus, the actual databases to be searched for while specifying the configuration database should be ‘AdfsConfigurationV3’.
• If the OS version of the ADFS node server is ‘Windows Server 2012 R2’, then the FBL will be ‘1’ and the ADFS Configuration Database name will be ‘AdfsConfiguration’ while the OS version, if it is ‘Windows Server 2019’, then the FBL will be ‘4’ and ADFS Configuration Database name will be ‘AdfsConfigurationV4’. Also, you should check for the ‘AdfsConfigurationV3.mdf’, ‘AdfsConfigurationV3_log.ldf’, ‘AdfsArtifactStore.mdf’ and ‘AdfsArtifactStore.ldf’ database files in the other ADFS Farm connected servers and accordingly try to form the connection string and connect to the right database.
• It is safe to detach the ADFS database through the SQL query from the original ADFS Server by using the queries below and then copying them and pasting them at a location where SQL databases are stored on the destination ADFS Server.
USE [master]
GO
EXEC master.dbo.sp_detach_db #dbname = N'AdfsArtifactStore'
GO
EXEC master.dbo.sp_detach_db #dbname = N'AdfsConfigurationV3'
GO
Once the ADFS databases are detached using the above query and pasted on the destination ADFS Server, execute the below SQL query to attach the copied databases to the ADFS Server and make it operational.
GO
CREATE DATABASE [AdfsConfigurationV3] ON
( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsConfigurationV3.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsConfigurationV3_log.ldf' )
FOR ATTACH
GO
USE [master]
GO
CREATE DATABASE [AdfsArtifactStore] ON
( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsArtifactStore.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsArtifactStore_log.ldf' )
FOR ATTACH
GO
ALTER DATABASE AdfsConfigurationV3 set enable_broker with rollback immediate
GO
Thus, in this way, you can detach and attach the latest ADFS Database to the preferred primary ADFS Server for it to be replicated and used. But for this, please ensure that you have the ‘OWNER’ permissions access to the ADFS databases in the original and the destination ADFS Servers respectively and while performing the above tasks, ensure that the ADFS Service is stopped and started only when the operation is complete. Post completion of the above tasks, ensure that the connection to the SQL Servers is possible by referring to the documentation link below: -
https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/troubleshooting/ad-fs-tshoot-sql
Also, refer to the link below for detailed information on the above: -
https://purple.telstra.com.au/blog/windows-server-2012-r2-adfs-3-0-migrating-adfs-configuration-database-from-wid-to-sql
Though the above link may not be discussing the issue that you are facing, but it resolves your queries to a greater extent.

How to query Azure Master DB from a Linked Server

I am trying to run this query from an instance on premise to the Master database in Azure.
I can query the other database on the Azure instance with my linked server so that is working and the query I'm trying to run, runs when I log onto the Azure instance.
I just cannot get it to run from my server that has a linked server object set up for Azure.
The code I have tried is:
SELECT [database_id],[name],[Compatibility_level],[collation_name],[state_desc]
,[recovery_model_Desc],[is_broker_enabled],[is_cdc_enabled]
FROM [LinkedServerName].[Master].[sys].[databases]
I have also tried it this way:
EXEC ( 'SELECT [database_id],[name],[Compatibility_level],[collation_name],[state_desc] ,[recovery_model_Desc],[is_broker_enabled],[is_cdc_enabled]
FROM [Master].[sys].[databases]') AT [LinkedServerName]
Again with no success. I am getting this error:
Msg 40515, Level 16, State 2, Line 9
Reference to database and/or server name in 'Master.sys.sp_tables_info_90_rowset_64' is not supported in this version of SQL Server.
Any ideas to help me get around this?
When you created the linked server you specified the user database as the “Catalog” database, you did not specified the master database as the catalog (the database used for the linked server). That is the reason you are using cross database queries, and cross database queries using three and four-part names are not supported on Azure SQL Database as explained here.
Additionally not all sys tables are supported on Azure SQL Database. You will find some DMVs available on Azure SQL Database that do not exist on SQL Server on-premises and vice versa.

AWS DMS does not support CDC/Change tracking for RDS SQL Server.

It does not seem that AWS DMS (Database Migration Service) supports CDC (change tracking) for RDS SQL Server. I am trying to create RDS SQL Server read-replicas to offload primary, for reporting. Also need a solution to continuously geo-replicate RDS SQL Server cross region from US East to West coast.
Any workarounds or alternative solutions ?
As a legacy method, SQL CDC does not work as it require a user with sysadmin privs in RDS which is impossible.
So, there is a workaround by Amazon to get this done. Follow below and use user who has db_owner.
1. --Enable CDC for RDS DB Instance
exec msdb.dbo.rds_cdc_enable_db '<database name>'
2.--Begin tracking a table
use <dbname_where_cdc_enabled>
exec sys.sp_cdc_enable_table
#source_schema = N'<source_schema>'
, #source_name = N'<source_name>'
, #role_name = N'<role name>'
, #capture_instance = '<capture_instance>'
--View CDC configuration
exec sys.sp_cdc_help_change_data_capture
That should do the work. For further clarification follow link.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.SQLServer.CommonDBATasks.CDC.html
Any workarounds or alternative solutions ?
You can create RDS SQL Server read-replicas to offload primary for reporting, as well as to continuously geo-replicate RDS SQL Server cross region from US East to West coast with CloudBasic's RDS SQL Server HA/DR tool available on the AWS Marketplace: https://aws.amazon.com/marketplace/pp/B00OU0PE5M
All SQL Server editions, including Web Edition are supported.
Launch it in the same AWS VPC as your RDS SQL Server source instance. In the New Replication setup section, ensure to select SQL Server-to-SQL Server replication (as the tool also streams data from SQL Server to Redshift and S3 data lakes).

Database Mirroring: Cannot set witness in Microsoft SQL Server 2014 using Azure

I am unable to connect to a witness server though Microsoft SQL Server 2014 for database mirroring. I am using Azure. Everything I have researched seems to point to this article https://support.microsoft.com/en-us/kb/940254 . But I cannot seem to get the DNS settings correct, or figure out how to set the host file, if that is even the fix.
I was mostly following this guide: https://msdn.microsoft.com/en-us/library/ms186384.aspx , for steps on setting up database mirroring.
Here is a brief summary of my scenario.
Principal Server
Cloud Service: MP
VM: MP (Windows Server 2012 R2 Datacenter)
Mirror and Witness Server
Cloud Service: MF
VM mirror: MF (Windows Server 2012 R2 Datacenter)
VM witness: MW (Windows Server 2012 R2 Datacenter)
I am getting this error when trying to run the SQL COMMAND:
ALTER DATABASE database SET WITNESS = 'TCP://MF.cloudapp.net:5023';
Msg 1456, Level 16, State 3, Line 1
The ALTER DATABASE command could not be sent to the remote server
instance 'TCP://MF.cloudapp.net:5023'. The database mirroring
configuration was not changed. Verify that the server is connected,
and try again.
I have opened specific ports on the firewall to allow connections and have set up Endpoints on the Azure portal. Any assistance you can provided will be very much appreciated.
In the meantime, I am going to try giving the witness server its own cloud service so the end points will all be the same (mentioned on this page: http://go4answers.webhost4life.com/Example/trouble-setting-witness-182317.aspx ). I also am going to try setting all 3 VMs on one cloud service then adding them to an availability set (mentioned on this page: https://cuteprogramming.wordpress.com/2014/10/16/database-mirroring-in-azure/ ).
Have you verified that there is bidirectional communication between the Database Mirroring replica and the Witness? Make sure that they can ping each other and that they are listening on their endpoints on both sides (check netstat). Make sure that the VMs are in the same VNET.
This happened to me twice and both times it was due to the SQL Server and agent service account. When I changed it to the Domain account I was able to add the witness in one shot.

MOSS 2007 Unable to Connect to Database after Config Database Move

I am in the process of moving all our SharePoint DB's from a SQL 2005 server to a new 2008 server, and after moving the config database, everything seems ok, except when I click on "Timer Job Status" (under Central Admin > Operations > Global Configuration) I receive a "Unable to connect to database. Check database connection information and make sure the database server is running." error.
I get the following entries in the log regarding this:
12/03/2010
13:51:41.80
w3wp.exe
(0x09E0)
0x09AC
Windows SharePoint Services
General
8e2r
Medium
Possible mismatch
between the reported error with code =
0x8107053b and message: "Unable to
connect to database. Check database
connection information and make sure
the database server is running." and
the returned error with code
0x81020024.
12/03/2010
13:51:45.61
OWSTIMER.EXE
(0x0744)
0x0DD8
Windows SharePoint Services
Database
6f8e
Critical
SQL Database
'SP_Test_Config' on SQL Server
instance 'test-server' not found.
Additional error information from SQL
Server is included below. Cannot open
database "SP_Test_Config" requested by
the login. The login failed.
It should be noted that in order to ensure that it was no longer using the config database on the old server, I detached the original SP_Test_Config database in SQL Management Studio.
Obviously there are still references to the old SP_Test_Config database on the old 2005 server. How do I remove these references? Or, barring that, how do I move the config database in such a way that no references to the old 2005 server will remain?
Thank you in advance!
Not really an answer, but what we ended up doing (basically start from scratch using SQL Aliases):
First, create the SQL Server alias. This will make it so if you need to move the databases again in the future, you can just migrate all the databases to the new SQL Server, and change your SQL Server alias to point at that server. This should save you a lot of trouble and heartache in the future.
Run SQL Server Client Configuration Utility at: C:\Windows\System 32\cliconfig.exe.
Under the Alias tab, create a SQL Server Alias for the new SQL Server.
Now, recreate the farm.
Run stsadm -o preparetomove on all content DB's Backup all content DB's and copy to new SQL server
Remove all servers from farm using SharePoint Configuration Wizard
Recreate farm using SharePoint Configuration Wizard with the alias of the SQL Server you created above
Recreate all web apps with temp content DB's
Run stsadm -o deletecontentdb on all temp content databases created in step 4
Run stsadm -o addcontentdb using copied production databases as content database
Troubleshoot ad nauseum

Resources