|
1 | 1 | --- |
2 | 2 | title: "BACKUP CERTIFICATE (Transact-SQL) | Microsoft Docs" |
3 | 3 | ms.custom: "" |
4 | | -ms.date: "10/04/2018" |
| 4 | +ms.date: "04/23/2019" |
5 | 5 | ms.prod: sql |
6 | 6 | ms.prod_service: "sql-data-warehouse, pdw, sql-database" |
7 | 7 | ms.reviewer: "" |
@@ -64,24 +64,34 @@ BACKUP CERTIFICATE certname TO FILE ='path_to_file' |
64 | 64 | ``` |
65 | 65 |
|
66 | 66 | ## Arguments |
67 | | - *path_to_file* |
68 | | - Specifies the complete path, including file name, of the file in which the certificate is to be saved. This path can be a local path or a UNC path to a network location. The default is the path of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] DATA folder. |
69 | | - |
70 | | - *path_to_private_key_file* |
71 | | - Specifies the complete path, including file name, of the file in which the private key is to be saved. This path can be a local path or a UNC path to a network location. The default is the path of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] DATA folder. |
| 67 | + *certname* |
| 68 | + Is the name of the certificate to backup. |
| 69 | + |
| 70 | + TO FILE = '*path_to_file*' |
| 71 | + Specifies the complete path, including file name, of the file in which the certificate is to be saved. This path can be a local path or a UNC path to a network location. If only a file name is specified, the file will be saved in the instance's default user data folder (which may or may not be the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] DATA folder). For SQL Server Express LocalDB, the instance's default user data folder is the path specified by the `%USERPROFILE%` environment variable for the account that created the instance. |
| 72 | + |
| 73 | + WITH PRIVATE KEY |
| 74 | + Specifies that the private key of the certificate is to be saved to a file. This clause is optional. |
| 75 | + |
| 76 | + FILE = '*path_to_private_key_file*' |
| 77 | + Specifies the complete path, including file name, of the file in which the private key is to be saved. This path can be a local path or a UNC path to a network location. If only a file name is specified, the file will be saved in the instance's default user data folder (which may or may not be the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] DATA folder). For SQL Server Express LocalDB, the instance's default user data folder is the path specified by the `%USERPROFILE%` environment variable for the account that created the instance. |
72 | 78 |
|
73 | | - *encryption_password* |
| 79 | + ENCRYPTION BY PASSWORD = '*encryption_password*' |
74 | 80 | Is the password that is used to encrypt the private key before writing the key to the backup file. The password is subject to complexity checks. |
75 | 81 |
|
76 | | - *decryption_password* |
| 82 | + DECRYPTION BY PASSWORD = '*decryption_password*' |
77 | 83 | Is the password that is used to decrypt the private key before backing up the key. This argument is not necessary if the certificate is encrypted by the master key. |
78 | 84 |
|
79 | 85 | ## Remarks |
80 | 86 | If the private key is encrypted with a password in the database, the decryption password must be specified. |
81 | 87 |
|
82 | | - When you back up the private key to a file, encryption is required. The password used to protect the certificate is not the same password that is used to encrypt the private key of the certificate. |
83 | | - |
84 | | - To restore a backed up certificate, use the [CREATE CERTIFICATE](../../t-sql/statements/create-certificate-transact-sql.md)statement. |
| 88 | + When you back up the private key to a file, encryption is required. The password used to protect the private key in the file is not the same password that is used to encrypt the private key of the certificate in the database. |
| 89 | + |
| 90 | + Private keys are saved in the PVK file format. |
| 91 | + |
| 92 | + To restore a backed up certificate, with or without the private key, use the [CREATE CERTIFICATE](../../t-sql/statements/create-certificate-transact-sql.md) statement. |
| 93 | + |
| 94 | + To restore a private key to an existing certificate in the database, use the [ALTER CERTIFICATE](../../t-sql/statements/alter-certificate-transact-sql.md) statement. |
85 | 95 |
|
86 | 96 | When performing a backup, the files will be ACLd to the service account of the SQL Server instance. If you need to restore the certificate to a server running under a different account, you will need to adjust the permissions on the files so that they are able to be read by the new account. |
87 | 97 |
|
|
123 | 133 | [CREATE CERTIFICATE (Transact-SQL)](../../t-sql/statements/create-certificate-transact-sql.md) |
124 | 134 | [ALTER CERTIFICATE (Transact-SQL)](../../t-sql/statements/alter-certificate-transact-sql.md) |
125 | 135 | [DROP CERTIFICATE (Transact-SQL)](../../t-sql/statements/drop-certificate-transact-sql.md) |
| 136 | + [CERTENCODED (Transact-SQL)](../../t-sql/functions/certencoded-transact-sql.md) |
| 137 | + [CERTPRIVATEKEY (Transact-SQL)](../../t-sql/functions/certprivatekey-transact-sql.md) |
| 138 | + [CERT_ID (Transact-SQL)](../../t-sql/functions/cert-id-transact-sql.md) |
| 139 | + [CERTPROPERTY (Transact-SQL)](../../t-sql/functions/certproperty-transact-sql.md) |
126 | 140 |
|
127 | 141 |
|
128 | 142 |
|
0 commit comments