Skip to content

Instantly share code, notes, and snippets.

@jwestgard
Last active February 14, 2024 16:25
Show Gist options
  • Select an option

  • Save jwestgard/ecac78a3c47b2cc98156982f5730a0ef to your computer and use it in GitHub Desktop.

Select an option

Save jwestgard/ecac78a3c47b2cc98156982f5730a0ef to your computer and use it in GitHub Desktop.
Export and download objects from Dspace running in k8s
#!/bin/zsh
DIR='output'
for HANDLE in $@; do
ID=${HANDLE#http://hdl.handle.net/1903/*}
DEST="$DIR/$ID"
EXPORT_CMD="/dspace/bin/dspace export -t ITEM -i 1903/$ID -d /dspace/upload -n $ID"
DELETE_CMD="rm -rf /dspace/upload/$ID"
if [ -d $DEST ]; then
echo "$DEST exists; skipping..."
else
kubectl exec -it drum-0 -- /bin/bash -c "$EXPORT_CMD" && \
sleep 3 && \
kubectl cp --retries 10 drum-0:/dspace/upload/$ID $DEST && \
kubectl exec -it drum-0 -- /bin/bash -c "$DELETE_CMD"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment