Forum Discussion
Backup F5 BigIP using RestAPI and PowerShell (again?)
- May 12, 2023
okay, I did that: https://stackoverflow.com/questions/76230777/bigip-f5-ucs-backup-via-restapi-and-powershell/76231795#76231795
Working on the last step - how to delete a file from UCS when it is downloaded.
Then - how to upload it to SharePoint, but this is another story and already completed 🙂
Thanks for the link. I am going to share it with my team players to be reviewed.
But, anyway, having both options to compare will be smart.
I found two commands for saving-loading data and I need somebody who knows what is it to help me.
Save/Load config - tm/sys/config
Save/Load UCS - tm/sys/ucs
What does "config" and what does "USC"?
I am looking for an option to be able to restore all settings.
I did create a backup file using tm/sys/ucs but not sure if this is the right way. It looks like it is very simple (when everything is working):
$headers = @{
"Content-Type" = "application/json"
"X-F5-Auth-Token" = "$token"
}
$body = @{
"command" = "save"
"name" = "testBackup.ucs"
"includePrivateKeys" = $true
"isEncrypted" = $false
"description" = "This one is done from PowerShell"
} | ConvertTo-Json
$result = Invoke-RestMethod -Uri "https://$server/mgmt/tm/sys/ucs" -Method Post -Headers $headers -Body $body
Roman_Melekh So config is the configuration on the device and is essentially loading what is in the config file on the device when you use the load command and saving the CLI changes you made to the config file on the device. A UCS is an archive file of the entire configuration and all settings on the F5 device. Please keep in mind that, depending on the code version, the UCS uses a master-key to encrypt and decrypt certain pieces of configuration in the UCS backup. It is important that you save the master-key of the device in a secure location so if you ever have to replace your device with a new one because the existing failed you will have to set the master-key to the same one as it was before or the UCS will not load properly. The UCS also stores the license of the device which is a unique pairing to the previous device so you will have to use the appropriate load command with the UCS so it doesn't load the license. You can use command "f5mku -K" without the quotations to view the existing master-key.
- Roman_MelekhMay 12, 2023Altocumulus
okay, I did that: https://stackoverflow.com/questions/76230777/bigip-f5-ucs-backup-via-restapi-and-powershell/76231795#76231795
Working on the last step - how to delete a file from UCS when it is downloaded.
Then - how to upload it to SharePoint, but this is another story and already completed 🙂
- PauliusMay 12, 2023MVP
Roman_Melekh I'm glade this worked for you. You should be able to add onto the end of the script a command that issues a delete of the existing archive file, exactly the same as you did to create the file but in this case a delete. Good luck with the SharePoint piece and if you find that the primary issue has been resolved please mark the comment that solved this for you.
- Roman_MelekhMay 12, 2023Altocumulus
Yep, the command is here already:
function Delete-F5ArchiveFile { param ( [Parameter(Mandatory = $true)][string]$token, [Parameter(Mandatory = $true)][string]$server, [Parameter(Mandatory = $true)][string]$UCSFileName ) $headers = @{ "Content-Type" = "application/json" "X-F5-Auth-Token" = "$token" } $body = @{ "command" = "run"; "utilCmdArgs" = " -c `"rm -f /var/local/ucs/$UCSFileName`" " } | ConvertTo-Json $result = Invoke-RestMethod -Uri "https://$server/mgmt/tm/util/bash" -Method Post -Headers $headers -Body $body return $result }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com