The id does not change once the index pattern has been created. By default, Kibana assigns a random uuid during creation. The id can also be manually specified via the Advanced Options
in the index pattern creation wizard:
So you have to take care that the correct id is specified when creating the index pattern or when restoring from a backup.