Last active
July 19, 2022 13:12
-
-
Save zk-1/7a53ad7dbb9df3f76a0a6677e926b79a to your computer and use it in GitHub Desktop.
This scripts allows the batch archival of G Suite accounts, via the accompanying gam-archive.sh script
This file contains hidden or 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 G Suite accounts, via the accompanying gam-archive.sh script | |
# Author: Zoë Kelly ([email protected]) | |
# License: MIT | |
# Created: 2020 | |
# Updated: | |
## Note: The gam-archive.sh script should be in the same folder or else added to $PATH. The input file should have a list of G Suite users to be archived, each on a newline. The email prefix should be used, i.e. jsmith. | |
# Where to put logs | |
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