Forum Discussion

ictjl's avatar
ictjl
Icon for Altocumulus rankAltocumulus
Aug 26, 2016

Can I "export" ASM security policies (one or all) from CLI?

Is there a bash or tmsh command that can export ASM security policies from the CLI? Even on the box to /shared/tmp? I'd like to setup a daily cron job to export my ASM policies nightly. I have automated nightly archives, but it would be nice to have the granularity to restore an individual ASM policy rather than the entire ucs restore. I'm using this model to backup my LTM Data Group Lists nightly. I'm running 11.5.4.

 

5 Replies

  • 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

    • NickAD's avatar
      NickAD
      Icon for Cirrus rankCirrus

      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
  • MSZ's avatar
    MSZ
    Icon for Nimbostratus rankNimbostratus

    Kindly share the procedure to backup the ucs archive automatically.

     

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    save asm policy asm_policy_name xml-file file_name_to_save_to

  • Thank you Pinko_Commie, I am looking at trying to monitor Changes to the ASM from a FIM .. modify you script a little bit and I should be good!