You can go back to the potty training techniques you used in the past. It sounds like he is in a period of transition and sometimes that can make children (and adults!) regress back to younger behaviors. Be patient with him and work with him to relearn how to use the potty. Perhaps now would be a good time to talk to his school about it too. They may have some good ideas.
Sometimes at school, its difficult for the kids to get to the restrooms or they are scared to use them because of the older kids in there. And sometimes teachers won't let the kids out during the period. All can lead towards having to hold it too long and accidents happen.
At home, it sounds like this is only happening at night? When he wakes up - does he have a night light? This is different then a child wetting his bed. He actually gets up, but for some reason can't/won't make it to the bathroom. Which makes me wonder if its kind of scary for him to go a night? Lights or a good flashlight might help. Get a really neat flashlight. Perhaps one of those LED ones and tell him its a special one to use at night when he has to go and see if it makes a difference.
Also cut down the fluids at night. And the idea of seeing a Pediatrician if things don't get better is also a good idea.
Hi and welcome. He is 6 and a bit old for potty training so this has appeared to be a habit behavior. People of all ages take up habit behavior and as the saying goes we are creatures of habit. Just explain to him that this is not acceptable in your house and if he continues to stay with you he must use the toilet only. Ask him why he pees in his pants at school. He does know why hes doing it and you might get some insight from his answer.
You might want have a Pediatrician take a look at him as might be having a bladder problem also.