Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How-To Import #9

Open
768kb opened this issue Nov 11, 2021 · 1 comment
Open

How-To Import #9

768kb opened this issue Nov 11, 2021 · 1 comment

Comments

@768kb
Copy link

768kb commented Nov 11, 2021

Very cool how-to-export guide, thank you for sharing this.

I wonder how to import the same files into bitwarden, after doing a full-restore of the whole database? A Import script would be helpful too for migrations like bitwarden -> own-hosted bitwarden.

@domingo13
Copy link

I have stitched together a quick way of importing all the attachments. It requires that you have imported the json file first so the items exist in the database:

#!/bin/bash

# Set the path to the parent folder that contains the subfolders
parent_folder="./export/attachments"

# Loop through all subfolders in the parent folder
for item_folder in "$parent_folder"/*; do
  # Extract the item ID from the subfolder name
  item_id=$(basename "$item_folder")
  # Loop through all files in the item folder
  for file in "$item_folder"/*; do
    # Get the full path of the file
    file_path=$(realpath "$file")
    # Import the file as an attachment
    bw create attachment --file "$file_path" --itemid "$item_id"
  done
done

Before you run it you must login with "bw login" and export the session variable.
It hasn't been extensively tested, so use with care or as a skeleton for a more complete solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants