Skip to content

Instantly share code, notes, and snippets.

@peterrus
Created May 22, 2021 15:27
Show Gist options
  • Save peterrus/cb9217401c12240ea36581bd98521133 to your computer and use it in GitHub Desktop.
Save peterrus/cb9217401c12240ea36581bd98521133 to your computer and use it in GitHub Desktop.
Bitwarden full export (with attachments)
#!/usr/bin/env bash
set -e
FOLDER_NAME=bw-export-$(date "+%Y%m%d-%H%M%S")
mkdir $FOLDER_NAME
cd $FOLDER_NAME
export BW_SESSION=$(bw unlock --raw)
bw sync --session $BW_SESSION
bw export --output ./bitwarden.json --format json # bw export does not seem to accept the --session parameter, so you have to enter your password here again
bash <(bw list items --session $BW_SESSION | jq -r '.[] | select(.attachments != null) | . as $parent | .attachments[] | "bw get attachment --session $BW_SESSION \(.id) --itemid \($parent.id) --output \"./attachments/\($parent.id)/\(.fileName)\""')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment