Backing up Bitwarden including attachments

Sometimes you’ll need to export Bitwarden data, for example when handing over a project. This can be done for an org as follows:

# Create a json export that can be imported into other systems
bw export --format json --output myorg-bitwarden-export.json --organizationid eba3880c-370e-48f9-880c-90bb67f57b1b

# Create json export that contains additional information about attachments
bw list items --organizationid eba3880c-370e-48f9-880c-90bb67f57b1b > myorg-bitwarden-itemlist.json

# Export those attachments into folders that match the BW item items
bash <(jq -r '.[] | select(.attachments != null) | . as $parent | .attachments[] | "bw get attachment \(.id) --itemid \($parent.id) --output \"./attachments/\($parent.id)/\(.fileName)\""' myorg-bitwarden-itemlist.json)

There also seems to be a community tool called PortWarden that supports backing up and restoring BW items:
https://github.com/vwxyzjn/portwarden

References: