Question regarding LN node backups I have LN node running on c-lightning. I am performing ~/.lightning dir backups time-to-time.

Let's say after backup i open few new channels and withdraw rest of onchain funds to my electrum. Then i restore a backup.

What will happen to my node and its channels?

P.S. i have tried such scenario once. Onchain funds status after backup restore become 'spent'. i had to launch 'lightning-cli dev-rescan-outputs' to refresh onchain funds and get actual status. While my node lists channels in 'listfunds', i see that those channels become inactive. What is happening under the hood? what is the correct way of making and restoring node backups?
As pointed out in similar questions backups are tricky with lightning. In the case of lightning each payment channel is a 2 of 2 multisig wallet. One of the keys is in your possession and it differs for each channel but in generally is derived from your master key.

The masterkey in c Lightning is 32 byte and stored in binary in ./lightning/hsm_secret 

Unluckily it is not sufficient to backup your masterkey. Every channel has a so called state and an old state of the channel will yield problems (potentially a forceful close of the channel partner and them being able to claim your funds.) 

So here is what should happen :
If you turn off your node and make a backup of your lightning dir you will be able to restore that backup on this or a different machine and after turning on your lightning node everything should work as before. 

If however you change channel state before restori g your backup your channel partner and you will most likely see a mismatch and fail the channel which means they publish their latest state. If you are lucky it is your partner and you can claim your outputs. If not it is your node and your partner will probably throw in their penalty tx to claim all coins of the channel due to the channel breach. 

Generally under the hood after restart of a lightning node all peers are being connected again. If that does not work (because the other node might be offline) there will be inactive channels.