Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createOnDemandMssqlBackup Wait For Completion #61

Open
Bryan-Meier opened this issue Mar 25, 2024 · 12 comments
Open

createOnDemandMssqlBackup Wait For Completion #61

Bryan-Meier opened this issue Mar 25, 2024 · 12 comments

Comments

@Bryan-Meier
Copy link

Hello,

We have been using the older CDM Powershell module and are looking to move to this one. The equivalent to using the createOnDemandMssqlBackup mutation in the older CDM Powershell SDK allowed us to add a flag to wait for the job to complete. Can this flag be added to this mutation to bring its capabilities in line with the older SDK?

By not including that option it's now on the customer to write their own wait logic which we are struggling to find a cmdlet that will provide us the the status based on the job id let alone iterate on it until it finishes.

@guirava
Copy link
Collaborator

guirava commented Apr 17, 2024

Resolution here depends on first resolving #60
Engineering is still working on it, we will circle back.

@guirava guirava closed this as completed Apr 17, 2024
@guirava guirava reopened this Apr 17, 2024
@SahFari
Copy link

SahFari commented May 2, 2024

My work around:
$Status = Get-RscEventSeries -List | Where-Object {$_.ObjectId -eq $cdmdb.id} | Select-Object LastActivityStatus, ObjectType, ObjectId, ActivitySeriesId, Fid

    do {
        $Status = Get-RscEventSeries -List | Where-Object {$_.ObjectId -eq $cdmdb.id} | Select-Object LastActivityStatus, ObjectType, ObjectId, ActivitySeriesId, Fid
        Write-host "Backup is still running!"

    } while ( $Status.LastActivityStatus -ne 'SUCCESS' )

@clumnah
Copy link
Collaborator

clumnah commented May 3, 2024

Connect-Rsc @ConnectRsc
$RscAccount = Get-RscAccount
$ClusterName = ""
$RscCluster = Get-RscCluster -Name $ClusterName
$HostName = ""
$RscMssqlInstance = Get-RscMssqlInstance -RscCluster $RscCluster -HostName $HostName
$DatabaseName = ""
$RscMssqlDatabase = Get-RscMssqlDatabase -Name $DatabaseName -RscMssqlInstance $RscMssqlInstance

$RecoveryDateTime = Get-RscMssqlDatabaseRecoveryPoint -RscMssqlDatabase $RscMssqlDatabase -Latest
$RscRequest = New-RscMssqlRestore -RscMssqlDatabase $RscMssqlDatabase -RecoveryDateTime $RecoveryDateTime -FinishRecovery
$RscRequest

$query = New-RscQuery -GqlQuery jobInfo
$query.Var.input = New-Object RubrikSecurityCloud.Types.JobInfoRequest
$query.Var.input.accountname = $RscAccount.AccountId
$query.Var.input.requestId = $RscRequest.id
$query.Var.input.clusterUUID = $RscCluster.Id
$query.Var.input.type = "MSSQL_RESTORE"
$query.Var.input.additionalinfo = New-Object RubrikSecurityCloud.Types.JobInfoRequestDetails
$query.Var.input.additionalinfo.mssqlDbInfo = New-Object RubrikSecurityCloud.Types.MssqlDbInfo
$query.Var.input.additionalinfo.mssqlDbInfo.mssqlDbFid = $RscMssqlDatabase.id
# $Result = $query.Invoke()

do {
    $Result = $query.Invoke()
    $Result.Status
    Start-Sleep -Seconds 1
} until ($Result.Status -eq "SUCCESS" -or $Result.Status -eq "FAILURE")


$Result.Status

Change the values for $ClusterName, $HostName, and $DatabaseName to values for your environment.

Then in the code, change the line $query.Var.input.type = "MSSQL_RESTORE" to appropriate to your operation. The proper values are

  • MSSQL_LIVE_MOUNT
  • MSSQL_UNMOUNT
  • MSSQL_RESTORE
  • MSSQL_DELETE_LOG_SHIPPING
  • MSSQL_CREATE_LOG_SHIPPING
  • MSSQL_EXPORT
  • MSSQL_SNAPSHOT (coming soon) Must be on RSC version v20240506 or later)

@SahFari
Copy link

SahFari commented May 7, 2024

Tnx Chris.

@JVGH
Copy link

JVGH commented Jun 3, 2024

@clumnah, I want to periodically check the status of a snapshot export. There is no "cluster" setup. I have the source AG/instance/host/db names. How do I query that? The above sample code doesn't work since I do not have a cluster (nor is it possible to set it up by me, we mainly use it take snapshots periodically). Also, the service account doesn't have admin rights for security reasons.

After queuing up an export the response is something like this..
{
"EndTime": null,
"Id": "RESTORE_MSSQL_DB_1231dec8-85ca-4618-8c41-3ca61e371294_7abc9ac3-c1a3-4d77-ab11-4cca51bav8e4:::0",
"NodeId": null,
"Progress": null,
"StartTime": null,
"Status": "QUEUED",
"Error": null,
"Links": null
}

@clumnah
Copy link
Collaborator

clumnah commented Jun 4, 2024

I do not follow your question. If you are using Rubrik to backup a MSSQL Database, then you have to have a cluster to write the backups to. Can you clarify what you mean?

@JVGH
Copy link

JVGH commented Jun 4, 2024

@clumnah,

(from the above code sample)

$ClusterName = ""
$RscCluster = Get-RscCluster -Name $ClusterName

On the Rubrik's website, under Inventory > SQL Server Databases, I see a list of hosts/instances. They all have a Cluster (as shown in one of the columns on that list). When I put in that name, the GET-RscCluster doesn't return anything. So I assumed it required some other "cluster" info (e.g. on the Rubrik's UI/dashboard > Clusters tab, this shows "0 total clusters").

How do I get the data in that case? Also, the following query seems to require admin rights for the SA (believe this is the query being called for $RscAccount = Get-RscAccount). Giving that SA admin rights might not be possible at the workplace.

query QueryAccountId {
accountId
}

I'm trying to fetch status of an export I queued up at an interval. When I queue up an export, below is the response. How do I query the status for this id until it succeeds or fails? Your sample code seems to be the answer but I haven't had a success with it for aforementioned reasons.

{
"EndTime": null,
"Id": "RESTORE_MSSQL_DB_1231dec8-85ca-4618-8c41-3ca61e371294_7abc9ac3-c1a3-4d77-ab11-4cca51bav8e4:::0",
"NodeId": null,
"Progress": null,
"StartTime": null,
"Status": "QUEUED",
"Error": null,
"Links": null
}

@clumnah
Copy link
Collaborator

clumnah commented Jun 4, 2024

I think this will be best served via a Support Ticket. This is is no longer about the SDK and about the RBAC permissions you need to get the cluster info and account name.

You can shortcut the account name by looking at your RSC URL and take the part before the my.rubrik.com. However not having cluster info will be a bigger issue that you still need to solve. While you may not be using replication now, if you do, you wont be able to do actions without the cluster object.

I can help the support tech once the ticket is in if they need it.

@JVGH
Copy link

JVGH commented Jun 4, 2024

@clumnah : There's is already an open support ticket. If you are ok, may I shoot you an email (at the email specified in your profile) with the ticket number (unsure if DM's work on github)?

@ChrisM-Dev
Copy link

The graphql response to this says "only user with Admin or Owner role allowed to access the field".

@clumnah
Copy link
Collaborator

clumnah commented Jun 6, 2024

@clumnah : There's is already an open support ticket. If you are ok, may I shoot you an email (at the email specified in your profile) with the ticket number (unsure if DM's work on github)?

Yes, that is fine.

@SahFari
Copy link

SahFari commented Aug 8, 2024

-WaitForCompletion works after upgrade to Rubrik cmdlet (9.0.1)

$Database_ids | ForEach-Object{

    $backup_job = New-RubrikSnapshot -id $_ -SLA $Sla -Confirm:$false

    Get-RubrikRequest -id $backup_job.id -Type mssql -WaitForCompletion #-Verbose

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants