We will use rclone tool to duplicate folders in this example on a shared Google drive.
First download the standalone binary e.g.
wget https://downloads.rclone.org/v1.66.0/rclone-v1.66.0-linux-amd64.zip unzip rclone-v1.66.0-linux-amd64.zip
Use this method when you need to manipulate your own drive and you can authenticate via browser e.g. on your local machine. Simply follow instructions from here
This is useful when you need to run the rclone tool from some other server which doesn't have web browser installed to authenticate and you have paid Google Workspace account and when you want to synchronise files onto machines that don't have actively logged-in users, for example build machines.
Instructions are adapted from here.
Go to https://console.developers.google.com/apis/api/drive.googleapis.com/overview and enable the API. (under Google Console > APIs & Services)
Contact your Google Workspace admin and allow access for the service account's Client ID howto here
After that is done follow steps 3 and 4 to make sure it works
This is another way to authorize the rclone. Just follow the steps here. Either way should work.
Some screenshots
Show help:
./rclone -h
List existing remotes:
./rclone listremotes
Copy folder inside the my_remote using service account method. This reads the secrets from downloaded json;
./rclone -v --drive-impersonate me@gmail.com copy 'my_remote:folder1' 'my_remote:folder1_copy'
Copy folder inside the my_remote using Google OAuth account. The client's id's and secret is also obtained from the json you get from finishing the OAuth steps and can be used on cmd line.
./rclone -v --drive-impersonate me@gmail.com --drive-client-id 'xxxxxxx194eq.apps.googleusercontent.com' --drive-client-secret 'xxxx' copy 'my_remote:folder1' 'my_remote:folder1_copy'