SHARE
TWEET

New Readme

a guest Jul 12th, 2019 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Requirements for using the scripts
  2. ---------------------------------
  3. * Python 3.7+
  4. * The following modules from pip3: `oauth2client`, `google-api-python-client`, `progress` & `httplib2shim`
  5.  
  6. Steps to make the required accounts for cloning
  7. ---------------------------------
  8. 1) Figure out how many projects you will need to make. For example, a 100TB clone job will take approximately 135 SAs to make a full clone. Each project can have a maximum limit of 100 SAs. Incase of the 100TB job, we will need 2 projects.
  9. 2) Head over to <https://console.developers.google.com/> and sign in with your account.
  10. 3) Click "Library" on the left column, then click on "Select a project" at the top. Click on `NEW PROJECT` on the top-right corner of the new window.
  11. 4) In the Project name section, input any project name you chose. Keep a note of the Project ID for each project that you make.
  12. 5) Repeat Steps 3 & 4 to create the amount of projects needed for your clone job.
  13. 6) Wait till the project creation is done and then click on "Select a project" again at the top and select your first project.
  14. 7) In the "Search for APIs & Services" search bar, look for "Google Drive API", click on it and press `ENABLE`. Do the same for "Identity and Access Management (IAM) API". Repeat this step for all the projects made.
  15. 8) Click on the Google APIs logo on the top-left, select your first project, and then go to `IAM & admin -> Service accounts` from the left pane. Next, press the blue `Create Service Account` button. In the Service account name section, input any name you want. Copy down the full Service account ID from your first project only, you will need this later. After that, press CREATE.
  16. 9) Click on `Select a role` and scroll down to `Service Accounts`. From there, enable `Create Service Accounts`. Click on the blue `+ ADD ANOTHER ROLE` and add `Service Account Key Admin` as role and press Continue. Then Press `+ Create Key`. Make sure the Key type is selected as JSON, and press CREATE. This should prompt you to save a JSON file. Save it in whereever the default download directory is for now.
  17. 10) Add the emaill address copied in Step 8 and add this to your other project with the same roles as mentioned in Step 9. You can do this by clicking on Google APIs logo on top left, selecting the project you want to share the email address with, then click on the Navigation menu icon which to the left of Google APIs logo, click `IAM & admin > IAM`. Now press  the blue `+ ADD` button, add the email address copied in Step 8, select the roles from step 9 and then press save. Repeat this for all the projects except the first project.
  18. 11) Place the JSON file you saved in a folder called `controller` and place the `controller` folder alongside with the 4 scripts.
  19. 12) Open terminal in the scripts folder and run the following command. `python3 serviceaccountfactory.py`.
  20. 13) It should automatically enter the project id and the number of accounts to create for the first project. Add all the other project ids and set accounts to create as 100. After you are done adding all, just press enter.
  21. 14) Enter any email prefix you want to use for your SAs and press enter. It should start making all the service accounts.
  22.  
  23. Steps to add all the SAs to the Shared Drive
  24. ---------------------------------
  25. 1) Once the previous script is done making all the accounts, open Google Drive and make a new Shared Drive to copy all the files to.
  26. 2) Add the address mentioned by the script as a Manager to the Shared Drive.
  27. 3) Run the following command `python3 masshare.py [SDFolderID]`. Replace the `[SDFolderID]` with `XXXXXXXXXXXXXXXXXXXXXXXXX`. The Folder ID can be obtained from the Shared Drive Folder Link `https://drive.google.com/drive/folders/XXXXXXXXXXXXXXXXXXXXXXXXX`. This will add all the service accounts to your Shared Drive.
  28.  
  29. Steps to clone a public folder to the Shared Drive (Single Threaded)
  30. ---------------------------------
  31. 1) Run the following command, `python3 folderclone.py 1 [SourceFolderID] [SDFolderID]`. Replace `[SourceFolderID]` with the folder ID of the folder you are trying to copy and replace `[SDFolderID]` with the same ID as used in step 3 in `Steps to add all the SAs to the Shared Drive`. It should start cloning the source folder to the Shared Drive at this point if everything was done correctly.
  32.  
  33. Steps to clone a public folder to the Shared Drive (Multi Threaded)
  34. ---------------------------------
  35. 1) Run the following command, `python3 multifolderclone.py [SourceFolderID] [SDFolderID]`. Replace `[SourceFolderID]` with the folder ID of the folder you are trying to copy and replace `[SDFolderID]` with the same ID as used in step 3 in `Steps to add all the SAs to the Shared Drive`. It should start cloning the source folder to the Shared Drive at this point if everything was done correctly.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top