How to grep Rules to search for a deprecated function? I'm removing an obsolete custom module, but I want to make sure it isn't referenced in any rules.

Is there a way for me to search / grep for a function name within all the rules on my site?
Consider a rule, actually a rules component, as in this (random) sample (in Rules export format):

{ "rules_grant_access_to_a_node" : {
    "LABEL" : "Grant access to a node",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "node_containing_classified_ad" : { "label" : "Node containing classified ad", "type" : "node" } },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node-containing-classified-ad" ],
          "type" : { "value" : { "article" : "article" } }
        }
      }
    ],
    "DO" : [
      { "entity_fetch" : {
          "USING" : {
            "type" : "node",
            "id" : [ "node-containing-classified-ad:field-free-format-nr" ]
          },
          "PROVIDE" : { "entity_fetched" : { "fetched_classified_complete" : "Fetched classified complete" } }
        }
      },
      { "drupal_message" : { "message" : "Trying to grant access to node with Id = [fetched-classified-complete:field_free_format_nr]" } },
      { "content_access_action_user_grant" : [] },
      { "redirect" : { "url" : [ "fetched-classified-complete:url" ] } }
    ]
  }
}


The above rule (Rules Component) has a Rules Action content_access_action_user_grant (= machine name) which is available if (a) you have the Content Access module enabled and (b) the ACL module is enabled also. So ACL is a weak module dependency of the Content Access module.

However, that content_access_action_user_grant Rules Action is only available if, and for as long as, ACL is enabled (if you disable the ACL module, then any rule that refers to that Rules Action content_access_action_user_grant will show a "... fails the integrity check").

With the above example (and Rules Action) in mind, execute an SQL query on the Drupal database which looks like so:

SELECT id,plugin,name,label
FROM `rules_config`
WHERE `data` LIKE '%content_access_action_user_grant%'


The results I get by using this query looks like so:

id  plugin   name                             label

216 rule     rules_grant_access_to_a_node     Grant access to a node


Obviously, this result with id=216 matches with my (random) sample rule.

To execute the above query, you can use whatever SQL query tool, such as PhpMyAdmin.

Replace the machine name of the Rules Action in my example by whatever fits with your "function name" (as in your question), and a similar SQL query should list all "rules in your site" (as in your question) that reference your custom module.

Note: another approach (if you can afford to do so), is to simply disable your custom module, and then use the Rules UI to find out which Rules / Rules Components show a similar message containing such "... fails the integrity check".