Wanted : script to download/archive all Document files

rickfillionrickfillion Junior Member

Team Member

When exporting to 1pif from our apps, we don't export Document files because the app doesn't necessarily have file cached, and the 1pif format doesn't really have a great place for those to live (they're like attachments but not quite).

It'd be nice to have a script that can be used that looked at every vault that I have access to and downloads/decrypts all document files into a directory structure like /%{vaultUUID}/%{documentUUID}/%{fileName}. This way I'd have a way of exporting all Documents if I need to.

Bonus points for accepting a vault name or vault uuid as a parameter to only get a single vault's worth. :)

Comments

  • svondutchsvondutch

    Team Member

    @rickfillion Something like this maybe?

    SESSION=$(op login $1 $2 $3)
    if [ $? != 0 ]; then
        echo $SESSION
        exit $?
    fi
    
    VAULTS=$(op vaults $SESSION)
    if [ $? != 0 ]; then
        echo $VAULTS
        exit $?
    fi
    
    for VAULT in $(echo $VAULTS | jq -r '.[]'); do
        DOCUMENTS=$(op documents $SESSION $VAULT)
        for DOCUMENT in $(echo $DOCUMENTS | jq -r '.[]'); do
            FILENAME=$(op item $SESSION $DOCUMENT | jq -r '.documentAttributes.fileName')
            mkdir -p $VAULT/$DOCUMENT
            op document $SESSION $DOCUMENT > $VAULT/$DOCUMENT/$FILENAME
        done
    done
    

    Here's how to invoke that:

    1. save the above script as download.sh
    2. open Terminal
    3. chmod u+x download.sh
    4. ./download.sh fillion.1password.com [email protected] A3-XXXXXX-XXXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    P.S. This script requires the use of jq: https://stedolan.github.io/jq/

  • rickfillionrickfillion Junior Member

    Team Member

    Ohhhh... that looks promising! Can't wait to try it out.

    Rick

This discussion has been closed.