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

Feature request implement command to Backup to location #13

Open
daerhtthread opened this issue Jan 14, 2020 · 4 comments
Open

Feature request implement command to Backup to location #13

daerhtthread opened this issue Jan 14, 2020 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@daerhtthread
Copy link

Backup to location like for the oneview PS lib "New-HPOVBackup -Location $Location "

thanks in advance.

@rumart rumart added the help wanted Extra attention is needed label Jan 26, 2020
@rumart
Copy link
Collaborator

rumart commented Jan 26, 2020

Hi
I'm not working much with Global Dashboard or OneView anymore, and I don't have access to any environment with them either.
Going to leave the issue open if anyone wants to help

@stephan-koch
Copy link

there is an settings inside the OVGD to schedule a backup, If this is not sufficient you could schedule it also with an script with the follwing rest commands:

Login:
OVGDIP=10.0.X.X

sessionID=$(curl -s -X POST
https://${OVGDIP}/rest/login-sessions
-H 'Content-Type: application/json'
-H 'X-API-Version: 2'
-k
-d '
{
"authLoginDomain":"local",
"password":"XXXXXX",
"userName":"localUser"
}' | jq -r ".sessionID")

#create an Backup
curl -s -X POST
https://${OVGDIP}/rest/backups
-H 'Content-Type: application/json'
-H "auth: $sessionID"
-H 'x-api-version: 2'
-k | python -m json.tool

#getting downloadURI
BACKUPURI=$(curl -s -X GET
https://${OVGDIP}/rest/backups
-H 'Content-Type: application/json'
-H "auth: $sessionID"
-H 'x-api-version: 2'
-k| jq -r ".members[].downloadUri " )
echo $BACKUPURI

#download the backup
TAG=$(date +%d%m%Y)
OUTFILE="OVGD-Backup.$TAG.bkp"

curl -s -X GET
https://${OVGDIP}$BACKUPURI
-H 'Content-Type: application/json'
-H "auth: $sessionID"
-H 'x-api-version: 2'
-k -o $OUTFILE

Tried it in an curl/Linux env, but perhaps not too hard to translate to POSH??

@daerhtthread
Copy link
Author

daerhtthread commented Jan 26, 2020 via email

@stephan-koch
Copy link

here an example for an POSH script which could certainly improved, but my POSH knowledge is really basic:

$IP="10.0.XX,XX"

#if(!$Password){

$Password = (Read-Host -Prompt "Type your password" -AsSecureString)

}

#for some SSL / Security reasons ....
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }

$code = @"
public class SSLHandler
{
public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler()
{

    return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });
}

}
"@

#compile the class
Add-Type -TypeDefinition $code

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler()

#Creation of the header
$headers = @{}
#$headers["Accept"] = "application/json"
$headers["x-api-version"] = "2"

$body = @{}
$body["authLoginDomain"] = "local"
$body["password"] = "XXXX"
$body["userName"] = "localuser"
$bodyjson = $body | ConvertTo-Json

$Connection=Invoke-WebRequest -Uri "https://$IP/rest/login-sessions" -ContentType "application/json" -Headers $headers -Method POST -UseBasicParsing -Body $bodyjson

$key=(${COnnection}.Content | ConvertFrom-Json).token
#$key

$headers["auth"] = $key

#Creating the body with the deployment group URI
$Createbackup = Invoke-WebRequest -Uri "https://$IP/rest/backups" -ContentType "application/json" -Headers $headers -Method POST -UseBasicParsing -Body $bodyjson

#wait for the backup to complete
Start-Sleep 120

#get DownloadURI
$Download = Invoke-WebRequest -Uri "https://$IP/rest/backups" -ContentType "application/json" -Headers $headers -Method GET -UseBasicParsing
$DownloadURI = (${Download}.Content | ConvertFrom-Json).members.downloadUri

#download it ...
#write-host $IP$DownloadURI
Invoke-WebRequest -Uri "https://$IP$DownloadURI" -ContentType "application/json" -Headers $headers -Method GET -UseBasicParsing -OutFile OVGD.bkp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants