If I remember correctly, iptables comes with two programs called: iptables-save and iptables-restore.
You can use these to save and restore your rules from a script.

~netRealm