Just some hints. I wrote a few helper functions for similar purposes.

MaskToPattern(mask,sw) ; mask with * and ? -> M pattern
 ; $$MaskToPattern^Idea.System.ZIF("ABC?D*") -> 1"ABC"1E1"D".E
 ; sw .. used for contains test (.E on both ends) : $$MaskToPattern^Idea.System.ZIF("ABC?D",1) -> .E1"ABC"1E1"D".E

and

MATCH(input,mask) ; matches input string against search mask

-> $$MATCH^Idea.System.ZIF("CSVZ","CST*")=0, $$MATCH^Idea.System.ZIF("CSVZ","CSV*")=1
MATCHOR(input,masklist) ; matches input string against list of search masks with OR condition (at least one)

-> $$MATCH^Idea.System.ZIF("CSVZ","CSV*,PF*")=1
MATCHAND(input,masklist) ; matches input string against list of search masks with AND condition (all must fit)

-> $$MATCH^Idea.System.ZIF("CSVZ","CSV*,PF*")=0


My implementation :

 MaskToPattern(mask,sw) pattern,char,pos pattern="",char="" pos=1:1:$L(mask) D
 . $E(mask,pos)="*" pattern=pattern_$S(char="":"",1:"1"""_char_"""")_".E",char="" Q
 . $E(mask,pos)="?" pattern=pattern_$S(char="":"",1:"1"""_char_"""")_"1E",char="" Q
 . char=char_$E(mask,pos)
 pattern=pattern_$S(char="":"",1:"1"""_char_""""),char="" S:$G(sw) pattern=".E"_pattern_".E"
 pattern

MATCH(input,mask) input?@$$MaskToPattern^Idea.System.ZIF(mask)
MATCHOR(input,list) ok,pie,mask ok=0 pie=1:1:$L(list,",") mask=$P(list,",",pie) mask'="",$$MATCH^Idea.System.ZIF(input,mask) ok=1 Q
 ok
MATCHAND(input,list) ok,pie,mask ok=1 pie=1:1:$L(list,",") mask=$P(list,",",pie) mask'="",'$$MATCH^Idea.System.ZIF(input,mask) ok=0 Q
 ok

Hi Alexey,

- yes, exacly, we scan the queue during backup node  startup

- the code is separated and ready to be delayed/called manually later (but, we never had to do this, except while testing)

- we never had timing issue and did not worry about this, whether it takes few seconds or few minutes

- in fact all this process has quite a few substeps

  a) scan all changed "roles" and update them (together with updating necessary resources)

  b) scan all changed "users" and update them (together with updating necessary resources)

  c) update also changed passwords (ssh, hush, little bit tricky/dirty)

  d) sending notifying e-mail to administrators/monitoring SW, that "D/R scenario happened and this XY instance on that XY machine is up"

Pavel