Generate openssl keys:
openssl req -x509 -nodes -newkey rsa:2048 -keyout mysqldump-key.priv.pem -out mysqldump-key.pub.pem
Create a mysql default file:
# ~/.mysqldump
[mysqldump]
host = host.here.com
| DECLARE | |
| @last_execution_time DATETIME = DATEADD(MINUTE, -60, GETUTCDATE()) | |
| ;WITH FilteredRuntimeStats AS ( | |
| SELECT | |
| rs.runtime_stats_id, | |
| rs.plan_id, | |
| rs.last_execution_time, | |
| rs.count_executions, | |
| rs.avg_cpu_time, |
| -- Optimized Session Monitor with Query Plans (Works on both Azure SQL DB and SQL Server VM) | |
| -- Using READ UNCOMMITTED for minimal blocking during monitoring | |
| SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; | |
| GO | |
| ;WITH SessionMetrics AS ( | |
| SELECT | |
| er.session_id AS sid, | |
| er.blocking_session_id AS blocked_by, | |
| -- Accurate issue detection based on Microsoft documentation | |
| STUFF( |
| -- Elastic Agent Jobs | |
| -- Official doc: https://learn.microsoft.com/en-us/azure/azure-sql/database/elastic-jobs-tsql-create-manage?view=azuresql | |
| -- Unofficial doc: https://sqlkitty.com/elastic-jobs-azure-sql-db/ | |
| -- Add target group | |
| EXEC jobs.sp_add_target_group 'AzureSQLDBs'; | |
| -- Add single database (or server/elastic pool) to target group | |
| EXEC jobs.sp_add_target_group_member | |
| @target_group_name = 'AzureSQLDBs', |
| - name: Get Azure CLI | |
| uses: azure/login@v1 | |
| with: | |
| creds: ${{ secrets.AZURE_CREDENTIALS }} | |
| - name: Get Terraform | |
| uses: hashicorp/setup-terraform@v1 | |
| with: | |
| terraform_version: 'latest' | |
| terraform_wrapper: false |
| { | |
| "annotations": { | |
| "list": [ | |
| { | |
| "$$hashKey": "object:690", | |
| "builtIn": 1, | |
| "datasource": "-- Grafana --", | |
| "enable": true, | |
| "hide": true, | |
| "iconColor": "rgba(0, 211, 255, 1)", |
| class Hash | |
| def strip | |
| StripperHash.new(self) | |
| end | |
| end | |
| class StripperHash < Hash | |
| def initialize(constructor = {}) | |
| if constructor.respond_to?(:to_hash) | |
| super |
Generate openssl keys:
openssl req -x509 -nodes -newkey rsa:2048 -keyout mysqldump-key.priv.pem -out mysqldump-key.pub.pem
Create a mysql default file:
# ~/.mysqldump
[mysqldump]
host = host.here.com
| #!/usr/bin/env bash | |
| # | |
| # Purpose: | |
| # Maintains 7 daily and 1 weekly database backups on a remote server. | |
| # | |
| # Configuration: | |
| # Subdirectories must be created on the remote server for each database. | |
| # (This includes status & fullschema directories if applicable.) | |
| # | |
| # Examples: |
| -- server 'sysadmin' | |
| SELECT name as 'sysadmin',type_desc,is_disabled | |
| FROM master.sys.server_principals | |
| WHERE IS_SRVROLEMEMBER ('sysadmin',name) = 1 | |
| ORDER BY name | |
| -- database owner | |
| select suser_sname(owner_sid) as 'owner' | |
| from sys.databases | |
| where name = DB_NAME() |
| /* | |
| ******************************************************************************************************************************** | |
| Credits: @Jeremy | |
| Posted: http://stackoverflow.com/questions/7048839/sql-server-query-to-find-all-permissions-access-for-all-users-in-a-database | |
| ******************************************************************************************************************************** | |
| Security Audit Report | |
| 1) List all access provisioned to a sql user or windows user/group directly | |
| 2) List all access provisioned to a sql user or windows user/group through a database or application role | |
| 3) List all access provisioned to the public role |