If you're on regularly, you can use markets as warehouses. When you see an attack coming, go to your level 4 market and put all your resources up for sale at a price so high nobody will buy them. Then, once the attack is past, just cancel the sale.