Wanted : script to download/archive all Document files
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
-
@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:
- save the above script as
download.sh
- open Terminal
chmod u+x download.sh
./download.sh fillion.1password.com rick@centrix.ca A3-XXXXXX-XXXXXX-XXXXX-XXXXX-XXXXX-XXXXX
P.S. This script requires the use of jq: https://stedolan.github.io/jq/
0 - save the above script as
-
Ohhhh... that looks promising! Can't wait to try it out.
Rick
0