Hi Everyone,
Hope you're all well. We're hoping that any of you could help us with the below scenario:
Short context:
- Environment: SQL Server 2008 R2 named instances and databases (including SharePoint) mirrored using Database Mirroring High Performance Asynchronous mode (it’s a requisite of who approached us) to a different server in a remote site. Same scenario for other SQL Server 2012 named instances and databases (for clarity sake: 2008 R2 servers mirror with 2008 R2 servers and 2012 with 2012, there is no mirror being made between different SQL Server versions).
- Challenge: Copy server logins (including all attributes, but mainly SID and server roles), database users (again, all attributes, but mainly owned schemas and roles) and SQL Server Agent Jobs, daily, to assure a delta <= 24 hours in case there is a need to activate the mirrored databases.
- Tested approaches that failed:
- SSIS:
- Transfer Logins Task: It creates the logins but it doesn’t copy server roles;
- Transfer Jobs Task: Fails with the majority of the jobs with error "The target database is a mirror database" and the jobs are not created in the remote instance.
- Jobs: SQL Server Agent Job that executes a PowerShell script that uses “sqlps” module to leverage CmdLets that connect to the main instances and outputs the jobs T-SQL to a *.sql file:
- Same as Transfer Jobs Task above (in a test environment, we tried to make the databases available and execute the T-SQL in the *.sql file but we still got a result that is not the desired one, but seeing a different error message, of course);
- Logins: SQL Server Agent Job that executes the stored procedure "sp_help_revlogins":
- Creates server logins with the same password and SID but fails to copy server roles, database users, owned schemas (we know, this sp just creates the users at server level).
- Logins: SQL Server Agent Job and Linked Server (DR > PRD) that executes the stored procedures documented in http://www.sqlsoldier.com/wp/sqlserver/transferring-logins-to-a-database-mirror:
- Same as above;
- Logins: SQL Server Agent Job and Linked Server (DR > PRD) that executes the stored procedure documented in http://media.tomaslind.net/2014/02/SctiptLogins.txt :
- Same as above.
- Logins: Manually right-click the server login or database user and selecting "Create to New Query Editor":
- Same as above.
-Logins: Chrissy LeMaire’s fantastic PowerShell “dbatools”:
- Same as above as “Copy-SqlServerRoles” is still under development and we lack scripting skills to complete it.
Thank you,
Regards,
RC