G Suite Account Archive-to-Drive (using Google Vault + GAM)

The G Suite offboarding features leave much to be desired, and IT teams will often end up bringing in services such as BetterCloud to automate the process. It is rare that GAM cannot solve a G Suite problem, so here is a GAM script that takes care of archiving a user’s email and/or Google Drive files, which would be run after the 1 or 3 month keep account active for forwarding/email delegation/OOO greeting period. In its current form it must be run from CLI, however a batch-run script is also included for convenience.
There does not seem to be any way to save the Vault export directly to Google Drive, so this workflow downloads the files and re-upload them programatically.

The script runs on the following basis:
1. Creates a Vault export
2. Waits for export to finish
3. Downloads the export files
4. Compresses the downloaded files
5. Uploads the archive to a specified Google Drive folder or shared drive
6. Deletes the local temporary files
7. Optionally deletes the user in G Suite


Leave a Reply

Your email address will not be published. Required fields are marked *