issue #19379: refactor the maintenance script