Skip to content

Instantly share code, notes, and snippets.

@leonjza
Last active February 22, 2024 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonjza/a5364c7a8577782aa4a29278ac0517a1 to your computer and use it in GitHub Desktop.
Save leonjza/a5364c7a8577782aa4a29278ac0517a1 to your computer and use it in GitHub Desktop.
extract a 1password 1pux exported organisation into separate vault exports

1Password 8 .1pux Vault Extrator

Looks like 1Password 8 only allows you to export whole organsations with all the vaults you have access to. Exporting to .1pux format means you can use this script to separate vaults into their own exports.

use

./separate.sh 1password_export.1pux

results

❯ ./separate.sh 1password_export.1pux
 i| processing 1password_export.1pux
 i| unpacking archive to tmp
 i| preparing exports directory: exports
 i| processing vault Private
 i| created Private.1pux
 i| processing vault Another Vault
 i| created another_vault.1pux
 
 [ ... snip ... ]
 
 i| cleaning up by removing tmp..
 
❯ ls
1password_export.1pux  Another_Vault.1pux  Private.1pux  separate.sh
#!/bin/bash
# a small helper script to convert a 1Password 8 account export
# into seperate vaults
# @leonjza, 2024
set -e
FILE=$1
TMP=tmp
EXPORTS=exports
echo " i| processing ${FILE}"
echo " i| unpacking archive to ${TMP}"
unzip -q $FILE -d $TMP
echo " i| preparing exports directory: ${EXPORTS}"
rm -Rf $EXPORTS
mkdir -p $EXPORTS
cat $TMP/export.data | jq -r ".accounts[].vaults[].attrs.name" | while read vault; do
echo " i| processing vault ${vault}"
vault_filename=$(echo "$vault" | tr ' ' '_' | tr -cd 'A-Za-z0-9_-.')
mkdir $vault_filename
cp -R $TMP/* $vault_filename
cat $TMP/export.data | \
jq --arg vault "$vault" '.accounts[] | {accounts: [{attrs: .attrs, vaults: [.vaults[] | select(.attrs.name == $vault)]}]}' \
> ${vault_filename}/export.data
(
cd $vault_filename
zip -q $vault_filename.1pux export.attributes export.data files
)
mv $vault_filename/$vault_filename.1pux .
rm -Rf $vault_filename
echo " i| created ${vault_filename}.1pux"
done
echo " i| cleaning up by removing ${TMP}.."
rm -Rf $TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment