#!/bin/bash #export4grading.sh #Create directory for export if it doesn't exist mkdir -p /shared/asm_policy_4grading #Set initial expoort date/time for tagging purposes export_date=`date +%Y_%m_%d-%H%M` #Enumerate all policy names and iterate through exporting twice for policy in `tmsh list asm policy one-line | awk '{print $3}'` do tmsh save asm policy $policy xml-file /var/tmp/${policy}_${export_date}.asmxml done for policy in `tmsh list asm policy /F5_TEST_ENVIRONMENT/* one-line | awk '{print $3}'` do tmsh save asm policy $policy xml-file /var/tmp/Test_${policy}_${export_date}.asmxml done for policy in `tmsh list asm policy /Integration_Env/* one-line | awk '{print $3}'` do tmsh save asm policy $policy xml-file /var/tmp/Integration_${policy}_${export_date}$ done #compress exported policy files and place in backup folder tar -zcvf /shared/asm_policy_4grading/ASM_Policies_${export_date}.tgz /var/tmp/*${export_date}* #clean up exported files post archive rm /var/tmp/*.asmxml