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
Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3
Please post ALL technical questions on the forum. Do not send private messages.