SQL Server: How to export database with linked servers
Linked servers are server-level objects--they are not contained within the database. Therefore you will need to move them separately.

In Management Studio, in the Object Explorer, Navigate to Server Objects --> Linked Servers --> [the linked server you want].



Then just right-click --> Script Linked Server as... --> CREATE to --> [pick a destination]. This will not script out passwords. 

If the linked server has stored credentials, you will need to re-input the password. You can either edit the call to sp_addlinkedsrvlogin in the generated script (replace "########" with the real password), or edit the linked server from Management Studio after creating it with the wrong password. Saving the script with the password embedded is not a good security practice, so I generally opt to either edit the script at runtime, or edit the authentication settings after the fact.