You can take the backup of
Master key as well as the Certificate with the below mentioned scripts:
From the Instance which you've restored from your backup
backup master key to file = 'c:\mk.dat'
encryption by password = 'Pass@12'
backup certificate mycert to file = 'c:\cert21.dat'
with private key(
encryption by password = 'sarab',
file = 'c:\cert21_key.dat')
To Restore the same on your test server Use these Scripts
restore master key from file = 'Z:\mk.dat'
decryption by password = 'Pass@12'
encryption by password = 'Pass@12'
create certificate mycert from file = 'Z:\cert21.dat'
with private key(file = 'Z:\cert21_key.dat',
decryption by password = 'sarab')
NOTE: Use Encryption by option while creating\Restoring Certificate\Master Key only if you specified the password while creating Master Key or Certificate on your server & use the same password in the ENCRYPTION BY option.
Test this if u face any problem, let me know.
Regards,
Sarabpreet Singh 😎
Sarabpreet.com
SQLChamp.com
Twitter: @Sarab_SQLGeek