svlsResearch / ha-mikrotik

High availability code for Mikrotik routers
156 stars 45 forks source link

wrong POSIX Regex for directory and file matching #8

Closed iptechnology-coelli closed 5 years ago

iptechnology-coelli commented 5 years ago

in hapushbackup.script you use `[/file find name~"^[^H][^A][^]" and type="directory"]and [find name~\"^[^H][^A][^]\" and type!=\"directory\"] This REGEX will skip ALL folders/files starting with an "H", all folders/files with an "A" as second char and all folders/files with a "" as a third char. I think that the right REGEX should be^([^H]|H($|[^A]|A($|[^]))).*and in MK: [/file find name~"^([^H]|H(\$|[^A]|A(\$|[^]))).*" and type="directory"] This will skip all folders/files starting with "HA_`"

Thanks Alessandro

nathanfaber commented 5 years ago

Good catch. I think I am actually going to get rid of the regex entirely and switch to something like:

:foreach k in [/file find type="directory"] do={
   :local xferfile [/file get $k name]
   if ([:pick "$xferfile" 0 3] != "HA_") do={ :put "Create dir: $xferfile" }
}
nathanfaber commented 5 years ago

Implemented 0ae761c8e4860b72b4bada9f709ecfef30dfe833