A simple c# console app that integrates with the Bitwarden CLI (Command Line Interface) to export your Bitwarden Vault
, utilizing Serilog
for logging and Spectre.Console
for console prompts.
- Bitwarden CLI Executable
- .NET 8.0 SDK
- Clone
Bitwarden-Backup
repository and build it, or download the corresponding release file. - Make a copy of the
appsettings-example.json
file and name itappsettings.json
.- The appsettings can be left as is and will run prompting you for all the needed values.
- Download and install
.NET 8.0 SDK
(See.NET 8.0 SDK Download
). - Download
Bitwarden CLI Executable
(SeeBitwarden CLI Download
). - Place the
Bitwarden CLI Executable
in the same directory as theBitwarden-Backup
executable
These options can be configured by setting the values for the keys in the appsettings.json file.
Key | Default | Example | Description |
---|---|---|---|
Serilog:MinimumLevel:Default |
Debug |
Information |
The minimum log event level written to the log file. See Serilog Minimum Level . |
Serilog:WriteTo:Args:path |
- | Logs/log.txt |
The file name or path to the file name. If the directories to the file names don't exist, it will be created. |
Serilog:WriteTo:Args:rollingInterval |
Infinite |
Day |
The frequency at which the log file should roll. See Serilog Rolling Interval . |
Serilog:WriteTo:Args:retainedFileCountLimit |
31 |
null |
The number of files to retain. |
Serilog:WriteTo:Args:shared |
false |
true |
By default, only one process may write to a log file at a given time. Setting this allows multi-process shared log files. |
Serilog:WriteTo:Args:outputTemplate |
{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception} |
{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u5}] {Message:lj}{NewLine}{Exception} |
The format for each log entry. See Serilog Formatting Output . |
ExportFile:Name |
bw_export |
C:\Temp\bw_export |
The path to place the exported file with the file name. |
ExportFile:DateInFileNameFormat |
- | yyyyMMdd |
When set, a date string based on the format is appended to the exported file name. See Format Specifier . |
ExportFile:Format |
json |
encrypted_json |
The file format of the exported file. See Export Format for all options. |
ExportFile:CustomExportPassword |
- | custompw |
When ExportFile:Format is set to encrypted_json and this is set, the file will be encrypted with this password instead of the Bitwarden's account encryption key. |
BitwardenConfiguration:Url |
- | https://your.bw.domain.com |
The Bitwarden server to connect to. |
BitwardenConfiguration:UserLogInMethod |
None |
EmailPw |
The method to log in to your Bitwarden vault. See Log In Method for all options. |
BitwardenConfiguration:EnableInteractiveLogIn |
true |
false |
If you want to be prompted for any missing but required values from the appsettings.json file. |
BitwardenConfiguration:ExecutablePath |
Executing Directory |
C:\Temp |
The path to the bw.exe file. |
Credentials:EmailPasswordCredential:Email |
- | [email protected] |
The email address for your Bitwarden vault. |
Credentials:EmailPasswordCredential:MasterPassword or Credentials:APIKeyCredential:MasterPassword |
- | bwpassword |
The master password for your Bitwarden vault. |
Credentials:EmailPasswordCredential:UserTwoFactorMethod |
None |
Email |
The two factor method to unlock your Bitwarden vault. See Two Factor Method for all options. |
Credentials:EmailPasswordCredential:TwoFactorCode |
- | 999999 |
The two factor code corresponding to the two factor method. |
Credentials:APIKeyCredential:ClientId |
- | user.clientId |
A value unique to your account. See Personal API Key for how to obtain it. |
Credentials:APIKeyCredential:ClientSecret or Credentials:EmailPasswordCredential:ClientSecret * |
- | clientSecret |
A unique value that can be rotated. See Personal API Key for how to obtain it. |
* For this ClientSecret
key under the key EmailPasswordCredential
, it will only be needed when Bitwarden CLI prompts for additional authentication. See CLI Authentication Challenges
.