Solution
Mappings are stored as a property of type DataSourceNode on the destination channel.
For example, consider the following mapping:

The corresponding DataSource record for the Global MetaData Out channel is shown below:

When a custom device is removed and replaced, the destination nodes associated with the mappings are recreated. As a result, the newly created nodes do not retain the original DataSourceNode property.
Mappings from a custom device output to another channel may be retained. However, mappings that reference custom device input channels are typically lost because the destination nodes are recreated during the replacement process.
To preserve mappings, export the mappings to a file before replacing the custom device. If mappings are lost after the replacement, import the previously exported mapping file to restore the configuration.