Mode Button - Script Doesn't Run

Hey Folks,

I have added a script to my router after finding a handy post about using the Mode button to revert to the last nightly backup (so for example it will get you out of trouble if you forgot to enable safe mode and messed up)

Running the script manually runs fine, but it fails when pressing the mode button despite the fact that it registers as having ran

Here are the components:

# Restore-From-Last-Backup script
/system script
remove [find name=Restore-From-Last-Backup]
add name=Restore-From-Last-Backup policy=reboot,sensitive,policy,password,test,read,write source={
    :log warning message="<LOG>Exporting backup before booting from last backup"
    /export file="export_before_boot_from_last_backup.rsc" 
    /system backup save name="backup_before_boot_from_last_backup.backup"
    :log warning message="<LOG>Rebooting from last nightly backup now!" 
    /system backup load name=usb1/nightly_backup.backup password=""
    y
}

/system scheduler
add comment="USB-backup every night at 00:00" interval=1d name=Do-Backup-Schedule on-event="/system script run Do-Backup" policy=ftp,read,write,policy,test,sensitive \
    start-date=1970-01-01 start-time=00:00:00

# Assign Restore-From-Last-Backup script to the mode button
/system routerboard mode-button
set enabled=yes on-event=Restore-From-Last-Backup

When I press the mode button, I get the following in the logs:

11:57:38 script,warning <LOG>Exporting backup before booting from last backup
11:57:38 script,error executing script Restore-From-Last-Backup from sys2 failed, please check it manually

Clearly the mode button is triggering the script, but why does it error via the button, and not when running it via the web?

System shows it ran, too:

6   ;;; Mode Button Reset
     name="Restore-From-Last-Backup" owner="xxx" policy=reboot,read,write,policy,test,password,sensitive dont-require-permissions=no last-started=2024-09-13 11:57:38
     run-count=1 source=
       :log warning message="<LOG>Exporting backup before booting from last backup"
       /export file="export_before_boot_from_last_backup.rsc"
       /system backup save name="backup_before_boot_from_last_backup.backup"
       :log warning message="<LOG>Rebooting from last nightly backup now!"
       /system backup load name=usb1/nightly_backup.backup password=""
       y

Looking at the files, I can see that it does not run the export or backup commands…yet the script clearly starts. Any ideas? My hunch is the ‘y’ to automatically run it, as I notice I have that issue via CLI (it waits for input) but if that was the case, I’d expect the logs from when I press the mode button to show more.

Thanks