There is no real defence against a plunder attack if an attacker gets past your defences they will take as many of your resources as their remaining troops can carry. However, you can protect these resources to some degree.
First use up your resources as much as you can do not stockpile. When you see an attack is coming sell all your resources in market. NB only do this if 1 gold = more than 1 resource (lumber,iron...) Then transport it to a fellow alliance member who is far enough away that it will NOT reach them before the attack is over. Recall troops after attack.
Or queue troops in your barracks, doesn't matter which troops you will not be recruiting them, before they reach the frontline you will cancel the training. You will get resources used back. NB. This ONLY works with troops don't try this with research in academy you will only get SOME resources back.
You can also hide your gold in a valley but remember these troops will eat twice as much as those garrisoned in your city and usually more than those you send away and recall.