Maybe there is a way if we store every new GCODE line in a file on SD card when it sends to 3D printer... So every time new GCODE command will be sent it will be saved in SD card and at the end of print that file will be removed from SD card. Now if power fails, on machine restart firmware will read SD card for backup file, if it finds file it means there was power failed and it will start printing from that last command...
Or on the other hand gcode file will be updated each time command is sent to printer and that command will be deleted from GCODE file. So when restore print will be started from GCODE, it will be the last position of file...