You'd have to read all the GPIO status and store that in a file or database, then on reboot read the file or database and restore the status. There's no ready-built way to do that stuff.
The GPIOs tend to start in a predictable state on a cold restart from power off/power on. On a warm restart (possibly done by shorting the RUN header) the status is less predictable.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+
Any DMs sent on Twitter will be answered next month.