Skip to content

Instantly share code, notes, and snippets.

@mestizo
Created March 5, 2021 11:22
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 mestizo/7df4c195312e8eee51e02724d5dbde19 to your computer and use it in GitHub Desktop.
Save mestizo/7df4c195312e8eee51e02724d5dbde19 to your computer and use it in GitHub Desktop.
script for Carey
#!/bin/bash
set -x
function usage() {
(
echo "usage: $0 <auth-token> <group-address> <mbox-dir>"
echo "To generate an auth token go to https://developers.google.com/oauthplayground/ and get an access token for Google Groups migration"
) >&2
exit 5
}
AUTH_TOKEN="$1"
shift
GROUP="$1"
shift
MBOX_DIR="$1"
shift
[ -z "$AUTH_TOKEN" -o -z "$GROUP" -o -z "$MBOX_DIR" ] && usage
for file in $MBOX_DIR/*; do
curl --progress-bar H"Authorization: Bearer $AUTH_TOKEN" -H'Content-Type: message/rfc822' -X POST \
"https://www.googleapis.com/upload/groups/v1/groups/$GROUP/archive?uploadType=media" --data-binary @${file} || exit 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment