How about a slight change? Use a power cord cable-clamped to the junction box, and plug that into the UPS. You could even cut your existing power cord and hardwire both ends to the NM, basically using it as a sort of in-wall extension.
Larry
www.fineelectricco.com