1PW CLI full backup of all items from all valuts

BSi
BSi
Community Member

Hi, I'm about to implement an automated backup and audit solution for our business vaults. The basic objective for 1PW CLI is to list all items in all vaults and export the whole content of them in JSON format for further processing.

It basically works for standard items, however I could not get it working properly for items which have file references (embedded files/attachments). For those items I did not find any way of exporting referred file/attachment.

I know that there is an option to manage document items, however these items are not document items, but standard (e.g. "LOGIN") items with file references.

How could I get 1PW CLI to export these files?

I'm using 1PW CLI v2.14.0


1Password Version: 8.10.3
Extension Version: Not Provided
OS Version: Windows 11
Browser:_ Not Provided

Comments

  • Hi @BSi, thanks for reaching out and sorry for the delay here.

    You should be able to export files attached to items using secret references. For example, op read op://Test/Item/file.pdf -o ~/Downloads/ will download the PDF file named file under Item item on the Test vault to your downloads folder.

    For bulk exporting of all items, you'll need to write a script to work through all the items, get the file names one-by-one and run op read for each file.

    Could you get it a try and let us know how it works for your needs?

  • BSi
    BSi
    Community Member

    Thanks @ArunV1P that did the trick. I've written a small script extracting base item data into JSON files, then parsing the JSON to extract the file references and finally extracting all attachments into an item specific subfolder.

    While this indeed works, when you have vaults with a few thousand items, the performance is abysmal. I've tested with 918 items, for which a total of 40 attachments were extracted, with the total size of 15 MB. The slowest part is actually not the attachment extraction, but the individual item extraction. It took 20 minutes and 43 seconds in a recent Debian install running under WSL2.

    As a comparison the whole account export started from the 1PW client (1PUX) took only 5 seconds.

    Is there any way of programmatically exporting data in bulk, like the 1PW client built-in export (1PUX) functionality? If not, then is it even on the backlog?

  • Racci
    Racci
    Community Member

    Looking for a solution here as-well, was using a service account but ran into api-limits due to having to make an indiviual request per item to get the full json

  • Hi @BSi !

    I see that you're on Windows, we currently don't have any caching on Windows, which is why you're seeing such terrible performance. We do have it on our backlog, but it's not a trivial change so we're still working to come up with a good solution. We've made a note about your concern and will reach back out when we know more.

    Sorry that I don't have better news!
    Amanda

This discussion has been closed.