GithubHelp home page GithubHelp logo

purestorage-openconnect / purestoragedbatools Goto Github PK

View Code? Open in Web Editor NEW
6.0 7.0 0.0 2.96 MB

Source code for the Pure Storage SQL Server DBA tools PowerShell module

License: Apache License 2.0

PowerShell 100.00%
sql-server-databases database powershell flasharray purestorage

purestoragedbatools's Introduction

Pure Storage DBA Tools PowerShell Module

This repository provides a PowerShell module with functions to refresh SQL Server databases, create snapshots of SQL Server databases and obfuscate sensitive data via SQL Server's dynamic data masking functionality. This functionality is currently provided by three functions:

- Invoke-PfaDbRefresh
- New-PfaDbSnapshot
- Invoke-StaticDataMasking
- Invoke-DynamicDataMasking

Getting Started

Prerequisites

This module is built on top of the dbatools and the PureStoragePowerShellSDK PowerShell modules, as such it has the following prerequisites:

  • Windows PowerShell 3.0 or higher .
  • .NET Framework 4.5 .
  • Purity Operating Environments that support REST API 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6 and 1.7 .
  • 64-bit Windows Server or Client operating system .
  • This release requires an operating system that supports the TLS 1.1/1.2 protocols such as Windows 7 or higher and Windows Server 2008 R2 or higher .
  • SQL Server 2008 SMO or SSMS .
  • SQL Server 2016 or above in order for the data masking functionality to work .

Installation

PureStorageDbaTools should always be downloaded and installed from the PowerShell gallery as follows:

PS> Install-Module -Name PureStorageDbaTools

Usage

Once installed, full documentation including example can be obtained on the three functions that the module contains via the Get-Help cmdlet:

Get-Help  Invoke-PfaDbRefresh 

will provide basic information on how the function can be used

Get-Help  Invoke-PfaDbRefresh -Detailed

will provide detailed information on how the function can be used including examples. Both the Invoke-PfaDbRefresh and New-PfaDbSnapshot functions use powershell credentials objects in order to comply with the security best practices and polices mandated by the Powershell gallery .

Calling Invoke-PfaDbRefresh, using the tpch-no-compression database on Z-STN-WIN2016-A\DEVOPSPRD is being used to refresh Z-STN-WIN2016-A\DEVOPSDEV1 and Z-STN-WIN2016-A\DEVOPSDEV2, the -ApplyDataMasks switch will cause the data masks to be applied:

Examples

$Pwd   = Get-Content ‘C:\Temp\Secure-Credentials.txt’ | ConvertTo-SecureString
$Creds = New-Object System.Management.Automation.PSCredential ("pureuser", $pwd)
$Targets = @('DEVOPSDEV1', 'DEVOPSDEV2')

Invoke-PfaDbRefresh -RefreshDatabase tpch          `
                    -RefreshSource   DEVOPSPRD     `
                    -DestSqlInstance $Targets      `
                    -PfaEndpoint     10.223.112.05 `
                    -PfaCredentials  $Creds `
                    -ApplyDataMasks

Restrictions

  • This code assumes that each database resides in a single FlashArray volume, i.e. there is one window logical volume per database
  • The code does not work with database(s) that reside on SQL Server failover instances
  • All database(s) used when performing a database to database refresh reside on the same FlashArray
  • The static data masking functionality currently works with char, varchar, nvarchar, int and bigint columns only

Authors

Chris Adkin, EMEA SQL Server Solutions Architect at Pure Storage.

License

This module is available to use under the Apache 2.0 license, stipulated as follows:

Copyright 2018 Pure Storage, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Acknowledgements

Thanks to the community behind the dbatools module .

Links

https://www.powershellgallery.com/packages/PureStorageDbaTools

https://www.purepowershellguy.com/?p=8431

purestoragedbatools's People

Contributors

chrisadkin8 avatar rlondner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

purestoragedbatools's Issues

Update to work with VM on VMFS and\or vVols

Requesting to update this project to support VMs on VMFS and\or vVols. Currently the SourceVolume and Sources for the Invoke-PfaDbRefresh and the New-PfaDbSnapshot respectively, won't match on the Serial #s from the Source Virtual Disk and the Volume on the PFA. These are the errors returned when running against a VM...

Invoke-PfaDbRefresh - gets "cannot bind argument to parameter 'SourceVolume' because it is an empty string"
New-PfaDbSnapshot - gets "failed to create snapshot for target database FlashArray Volume with: Cannot bind argument parameter 'Sources' because it is null"

Also for Example #5 for the Invoke-PfaDbRefresh - SQL to SQL seems to fails at the same place for the Serial # comparison even though the description says it is database to database without a snapshot. "Refresh a single database from the database specficied by the SourceDatabase parameter residing on the instance specified by RefreshSource" Is that the correct assumption?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.