Forum Discussion
Hi, there is tmsh command
save asm policy [asm policy name] xml-files
.
The problem should be that you can't use wild-cards for policy names. So you need to have the list of policies.
One possibility is:
tmsh list asm policy \/*\/* one-line | cut -d " " -f 3 > policies.txt
than run the loop to save them:
for i in $(cat policies.txt) do echo $i; save asm policy $i xml-file; done
(not tested, i have no box available now. may be you will have to escape the slashes (with back slashes)).
after that you will have the policies in /var/tmp/*.xml files. Filip
- NickADOct 28, 2020Cirrus
This thread has been up for a few years, so if there is anyone who stumbles on this today, you might need a couple of updates. I ran the following on v14.1.2 with success.
For exporting a list of ASM policies you can use:
tmsh list asm policy \* one-line | cut -d " " -f 3 > policies.txt
And then to use that list of policies to actually export the XML files you can use:
for i in $(cat policies.txt); do echo $i; tmsh save asm policy $i xml-file $i.xml; done
There was a missing semicolon after the policies.txt which is required. Additionally you need to add in the tmsh command prompt as this is ran in a bash shell. The last thing I added with the final '$i' to name the policy when it saved to /var/tmp
If you are running this on a regular basis and the XML files already exist, you will need to overwrite them.
for i in $(cat policies.txt); do echo $i; tmsh save asm policy $i xml-file $i.xml overwrite; done