NOTE: This is not an offical script from Tintri
To schedule snapshots from Tintri Global Center (TGC) using PowerShell and validate all snapshots, you can utilize the Tintri.Powershell module and export the snapshot details to a file for verification. Before running the script, ensure that you have the Tintri.Powershell module installed and authenticated to your TGC server.
Step 1: Install Tintri.Powershell Module: If you haven’t installed the Tintri.Powershell module yet, you can do so by running the following command in PowerShell (run PowerShell as an administrator):
Install-Module -Name Tintri.Powershell
Step 2: Authenticate to TGC: Before using the Tintri cmdlets, you need to authenticate to your TGC server using your credentials. Replace <TGC_Host> with the hostname or IP address of your TGC server.
$TgcHost = "<TGC_Host>"
Connect-TintriServer -Server $TgcHost
Step 3: Schedule Snapshots: With the Tintri.Powershell module, you can use the Get-TintriVm and New-TintriScheduledSnapshot cmdlets to schedule snapshots of a specific VM. Replace <VM_Name> with the name of the VM you want to schedule snapshots for, and specify the desired schedule using the -Repeat parameter.
$vmName = "<VM_Name>"
$vm = Get-TintriVm -Name $vmName
# Schedule snapshots of the VM to occur every day at 2:00 AM
New-TintriScheduledSnapshot -Vm $vm -SnapshotName "Scheduled_Snapshot" -Description "Daily Snapshot" -Repeat "Daily" -StartTime "02:00"
Step 4: Validate Snapshots and Export Details: To validate all snapshots for a specific VM and export the snapshot details to a file, you can use the Get-TintriSnapshot cmdlet with the -Vm parameter. Replace <VM_Name> with the name of the VM you want to validate snapshots for, and specify the output file path using the Out-File cmdlet.
$vmName = "<VM_Name>"
$vm = Get-TintriVm -Name $vmName
# Get all snapshots of the VM
$snapshots = Get-TintriSnapshot -Vm $vm
# Export snapshot details to a file
$snapshots | Out-File -FilePath "C:\Snapshot_Details.txt"
Explanation:
- The script starts by importing the
Tintri.Powershellmodule, allowing us to use the Tintri cmdlets. - We then connect to the Tintri Global Center (TGC) server using the
Connect-TintriServercmdlet, specifying the TGC server’s hostname or IP address. This step establishes the connection to the TGC server, and you will be prompted to enter your credentials to authenticate. - After connecting to TGC, we use the
Get-TintriVmcmdlet to fetch information about the specific VM we want to schedule snapshots for. We provide the name of the VM using the-Nameparameter, and the cmdlet returns the VM object. - We schedule snapshots of the VM using the
New-TintriScheduledSnapshotcmdlet. We pass the VM object obtained in the previous step to the-Vmparameter. We also provide a name and description for the scheduled snapshot using the-SnapshotNameand-Descriptionparameters, respectively. Additionally, we specify the desired snapshot schedule using the-Repeatparameter (e.g., “Daily”) and the-StartTimeparameter to set the time of the day when the snapshot will be taken. - To validate all snapshots for the specific VM, we use the
Get-TintriSnapshotcmdlet with the-Vmparameter, passing the VM object to it. The cmdlet retrieves all snapshots associated with the VM and stores them in the$snapshotsvariable. - Finally, we export the snapshot details to a file named “Snapshot_Details.txt” using the
Out-Filecmdlet. The-FilePathparameter specifies the output file path, and the contents of the$snapshotsvariable are written to the file.
By using this PowerShell script, you can schedule snapshots for a specific VM from Tintri Global Center and validate all snapshots by exporting their details to a text file. This automation simplifies snapshot management and provides an easy way to review and verify the snapshot status for the VM.