Restore from backup. See the restoring topic of:
If you restore from iTunes backup
To help prevent the last backup from being overwritten and thus erasing the Messages from the last backup turn off autosyncing so that you have to overtly start a sync. To turn off go iTunes>Preferences>Devices and check the box that says "Prevent iPods...".