Hello,
You can add the absolute file location of your script in file /etc/sysupgrade.conf
After that, your file will be included in the backup archive. Furthermore, the file will remain after the firmware upgrade.
Also, you could add custom scripts to the already downloaded backup archive and upload backup to the router. It will also upload the scripts.
Regards.