Created
May 16, 2018 05:27
-
-
Save guss77/44369c39b6ce0cfa488ef476ea477c0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
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 -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 |
Recommend changing --data-binary @${file}
to --data-binary @"${file}"
to fix issues with files having spaces.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've found https://github.com/XaviTorello/mail2googlegroup