This scripts allows the batch archival of Google Workspace accounts, via the accompanying gam-archive.sh script
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
#!/usr/bin/env bash | |
# Name: gam-batch-archive.sh | |
# Usage: cat archive_user_list.txt | gam-batch-archive.sh mail|drive|both | |
# Description: This scripts allows the batch archival of Google Workspace accounts, via the accompanying gam-archive.sh script | |
# Author: Zoë Kelly (zoe@starshade.ca), Kim Nilsson (github@no-substitute.com) | |
# License: MIT | |
# Created: 2020 | |
# Updated: 2022-07-19 | |
## Note: The gam-archive.sh script should be in the same folder or (preferably) in $PATH. | |
## Note: The input file should have a list of Google Workspace users to be archived, each on a new line. | |
## Note: The email prefix should be used, i.e. jsmith. The list should only have usernames, no header. | |
# Where to put logs | |
# You should definitely use a better path for this, and check the log after running the script. | |
log_path="$HOME/Desktop" | |
# --- --- --- --- --- --- --- --- --- --- | |
today_stamp=$(date "+%d-%m-%Y") | |
usage="Usage: cat archive_user_list.txt | $(basename "$0") mail|drive|both" | |
[ ! -t 0 ] && : || echo "No input detected - $usage - Press ctrl + C now" | |
the_users=$(cat /dev/stdin) | |
# If no paramater given, print usage and exit | |
if [ $# -lt 1 ]; then | |
echo "$usage" | |
exit | |
fi | |
export_type="$1" | |
for i in $the_users ; do | |
gam-archive.sh "$i" "$export_type" | |
echo "$today_stamp - Archived - $i" >> "$log_path"/gam-batch-archive.log | |
done | |
echo "Done. If there were no errors, it probably went fine." | |
echo "Log file: $log_path/gam-batch-archive.log" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adjusted "G Suite" to "Google Workspace", added a few informative notes, removed the ./ reference to gam-archive.sh, added double quoting for variables according to https://www.shellcheck.net/wiki/SC2086, and adjusted backtick commands according to https://www.shellcheck.net/wiki/SC2006