github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/docs/content/drive.md (about)

     1  ---
     2  title: "Google drive"
     3  description: "Rclone docs for Google drive"
     4  ---
     5  
     6  {{< icon "fab fa-google" >}} Google Drive
     7  -----------------------------------------
     8  
     9  Paths are specified as `drive:path`
    10  
    11  Drive paths may be as deep as required, eg `drive:directory/subdirectory`.
    12  
    13  The initial setup for drive involves getting a token from Google drive
    14  which you need to do in your browser.  `rclone config` walks you
    15  through it.
    16  
    17  Here is an example of how to make a remote called `remote`.  First run:
    18  
    19       rclone config
    20  
    21  This will guide you through an interactive setup process:
    22  
    23  ```
    24  No remotes found - make a new one
    25  n) New remote
    26  r) Rename remote
    27  c) Copy remote
    28  s) Set configuration password
    29  q) Quit config
    30  n/r/c/s/q> n
    31  name> remote
    32  Type of storage to configure.
    33  Choose a number from below, or type in your own value
    34  [snip]
    35  XX / Google Drive
    36     \ "drive"
    37  [snip]
    38  Storage> drive
    39  Google Application Client Id - leave blank normally.
    40  client_id>
    41  Google Application Client Secret - leave blank normally.
    42  client_secret>
    43  Scope that rclone should use when requesting access from drive.
    44  Choose a number from below, or type in your own value
    45   1 / Full access all files, excluding Application Data Folder.
    46     \ "drive"
    47   2 / Read-only access to file metadata and file contents.
    48     \ "drive.readonly"
    49     / Access to files created by rclone only.
    50   3 | These are visible in the drive website.
    51     | File authorization is revoked when the user deauthorizes the app.
    52     \ "drive.file"
    53     / Allows read and write access to the Application Data folder.
    54   4 | This is not visible in the drive website.
    55     \ "drive.appfolder"
    56     / Allows read-only access to file metadata but
    57   5 | does not allow any access to read or download file content.
    58     \ "drive.metadata.readonly"
    59  scope> 1
    60  ID of the root folder - leave blank normally.  Fill in to access "Computers" folders. (see docs).
    61  root_folder_id> 
    62  Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
    63  service_account_file>
    64  Remote config
    65  Use auto config?
    66   * Say Y if not sure
    67   * Say N if you are working on a remote or headless machine or Y didn't work
    68  y) Yes
    69  n) No
    70  y/n> y
    71  If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
    72  Log in and authorize rclone for access
    73  Waiting for code...
    74  Got code
    75  Configure this as a team drive?
    76  y) Yes
    77  n) No
    78  y/n> n
    79  --------------------
    80  [remote]
    81  client_id = 
    82  client_secret = 
    83  scope = drive
    84  root_folder_id = 
    85  service_account_file =
    86  token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2014-03-16T13:57:58.955387075Z"}
    87  --------------------
    88  y) Yes this is OK
    89  e) Edit this remote
    90  d) Delete this remote
    91  y/e/d> y
    92  ```
    93  
    94  Note that rclone runs a webserver on your local machine to collect the
    95  token as returned from Google if you use auto config mode. This only
    96  runs from the moment it opens your browser to the moment you get back
    97  the verification code.  This is on `http://127.0.0.1:53682/` and this
    98  it may require you to unblock it temporarily if you are running a host
    99  firewall, or use manual mode.
   100  
   101  You can then use it like this,
   102  
   103  List directories in top level of your drive
   104  
   105      rclone lsd remote:
   106  
   107  List all the files in your drive
   108  
   109      rclone ls remote:
   110  
   111  To copy a local directory to a drive directory called backup
   112  
   113      rclone copy /home/source remote:backup
   114  
   115  ### Scopes ###
   116  
   117  Rclone allows you to select which scope you would like for rclone to
   118  use.  This changes what type of token is granted to rclone.  [The
   119  scopes are defined
   120  here](https://developers.google.com/drive/v3/web/about-auth).
   121  
   122  The scope are
   123  
   124  #### drive ####
   125  
   126  This is the default scope and allows full access to all files, except
   127  for the Application Data Folder (see below).
   128  
   129  Choose this one if you aren't sure.
   130  
   131  #### drive.readonly ####
   132  
   133  This allows read only access to all files.  Files may be listed and
   134  downloaded but not uploaded, renamed or deleted.
   135  
   136  #### drive.file ####
   137  
   138  With this scope rclone can read/view/modify only those files and
   139  folders it creates.
   140  
   141  So if you uploaded files to drive via the web interface (or any other
   142  means) they will not be visible to rclone.
   143  
   144  This can be useful if you are using rclone to backup data and you want
   145  to be sure confidential data on your drive is not visible to rclone.
   146  
   147  Files created with this scope are visible in the web interface.
   148  
   149  #### drive.appfolder ####
   150  
   151  This gives rclone its own private area to store files.  Rclone will
   152  not be able to see any other files on your drive and you won't be able
   153  to see rclone's files from the web interface either.
   154  
   155  #### drive.metadata.readonly ####
   156  
   157  This allows read only access to file names only.  It does not allow
   158  rclone to download or upload data, or rename or delete files or
   159  directories.
   160  
   161  ### Root folder ID ###
   162  
   163  You can set the `root_folder_id` for rclone.  This is the directory
   164  (identified by its `Folder ID`) that rclone considers to be the root
   165  of your drive.
   166  
   167  Normally you will leave this blank and rclone will determine the
   168  correct root to use itself.
   169  
   170  However you can set this to restrict rclone to a specific folder
   171  hierarchy or to access data within the "Computers" tab on the drive
   172  web interface (where files from Google's Backup and Sync desktop
   173  program go).
   174  
   175  In order to do this you will have to find the `Folder ID` of the
   176  directory you wish rclone to display.  This will be the last segment
   177  of the URL when you open the relevant folder in the drive web
   178  interface.
   179  
   180  So if the folder you want rclone to use has a URL which looks like
   181  `https://drive.google.com/drive/folders/1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh`
   182  in the browser, then you use `1XyfxxxxxxxxxxxxxxxxxxxxxxxxxKHCh` as
   183  the `root_folder_id` in the config.
   184  
   185  **NB** folders under the "Computers" tab seem to be read only (drive
   186  gives a 500 error) when using rclone.
   187  
   188  There doesn't appear to be an API to discover the folder IDs of the
   189  "Computers" tab - please contact us if you know otherwise!
   190  
   191  Note also that rclone can't access any data under the "Backups" tab on
   192  the google drive web interface yet.
   193  
   194  ### Service Account support ###
   195  
   196  You can set up rclone with Google Drive in an unattended mode,
   197  i.e. not tied to a specific end-user Google account. This is useful
   198  when you want to synchronise files onto machines that don't have
   199  actively logged-in users, for example build machines.
   200  
   201  To use a Service Account instead of OAuth2 token flow, enter the path
   202  to your Service Account credentials at the `service_account_file`
   203  prompt during `rclone config` and rclone won't use the browser based
   204  authentication flow. If you'd rather stuff the contents of the
   205  credentials file into the rclone config file, you can set
   206  `service_account_credentials` with the actual contents of the file
   207  instead, or set the equivalent environment variable.
   208  
   209  #### Use case - Google Apps/G-suite account and individual Drive ####
   210  
   211  Let's say that you are the administrator of a Google Apps (old) or
   212  G-suite account.
   213  The goal is to store data on an individual's Drive account, who IS
   214  a member of the domain.
   215  We'll call the domain **example.com**, and the user
   216  **foo@example.com**.
   217  
   218  There's a few steps we need to go through to accomplish this:
   219  
   220  ##### 1. Create a service account for example.com #####
   221    - To create a service account and obtain its credentials, go to the
   222  [Google Developer Console](https://console.developers.google.com).
   223    - You must have a project - create one if you don't.
   224    - Then go to "IAM & admin" -> "Service Accounts".
   225    - Use the "Create Credentials" button. Fill in "Service account name"
   226  with something that identifies your client. "Role" can be empty.
   227    - Tick "Furnish a new private key" - select "Key type JSON".
   228    - Tick "Enable G Suite Domain-wide Delegation". This option makes
   229  "impersonation" possible, as documented here:
   230  [Delegating domain-wide authority to the service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority)
   231    - These credentials are what rclone will use for authentication.
   232  If you ever need to remove access, press the "Delete service
   233  account key" button.
   234  
   235  ##### 2. Allowing API access to example.com Google Drive #####
   236    - Go to example.com's admin console
   237    - Go into "Security" (or use the search bar)
   238    - Select "Show more" and then "Advanced settings"
   239    - Select "Manage API client access" in the "Authentication" section
   240    - In the "Client Name" field enter the service account's
   241  "Client ID" - this can be found in the Developer Console under
   242  "IAM & Admin" -> "Service Accounts", then "View Client ID" for
   243  the newly created service account.
   244  It is a ~21 character numerical string.
   245    - In the next field, "One or More API Scopes", enter
   246  `https://www.googleapis.com/auth/drive`
   247  to grant access to Google Drive specifically.
   248  
   249  ##### 3. Configure rclone, assuming a new install #####
   250  
   251  ```
   252  rclone config
   253  
   254  n/s/q> n         # New
   255  name>gdrive      # Gdrive is an example name
   256  Storage>         # Select the number shown for Google Drive
   257  client_id>       # Can be left blank
   258  client_secret>   # Can be left blank
   259  scope>           # Select your scope, 1 for example
   260  root_folder_id>  # Can be left blank
   261  service_account_file> /home/foo/myJSONfile.json # This is where the JSON file goes!
   262  y/n>             # Auto config, y
   263  
   264  ```
   265  
   266  ##### 4. Verify that it's working #####
   267    - `rclone -v --drive-impersonate foo@example.com lsf gdrive:backup`
   268    - The arguments do:
   269      - `-v` - verbose logging
   270      - `--drive-impersonate foo@example.com` - this is what does
   271  the magic, pretending to be user foo.
   272      - `lsf` - list files in a parsing friendly way
   273      - `gdrive:backup` - use the remote called gdrive, work in
   274  the folder named backup.
   275  
   276  ### Team drives ###
   277  
   278  If you want to configure the remote to point to a Google Team Drive
   279  then answer `y` to the question `Configure this as a team drive?`.
   280  
   281  This will fetch the list of Team Drives from google and allow you to
   282  configure which one you want to use.  You can also type in a team
   283  drive ID if you prefer.
   284  
   285  For example:
   286  
   287  ```
   288  Configure this as a team drive?
   289  y) Yes
   290  n) No
   291  y/n> y
   292  Fetching team drive list...
   293  Choose a number from below, or type in your own value
   294   1 / Rclone Test
   295     \ "xxxxxxxxxxxxxxxxxxxx"
   296   2 / Rclone Test 2
   297     \ "yyyyyyyyyyyyyyyyyyyy"
   298   3 / Rclone Test 3
   299     \ "zzzzzzzzzzzzzzzzzzzz"
   300  Enter a Team Drive ID> 1
   301  --------------------
   302  [remote]
   303  client_id =
   304  client_secret =
   305  token = {"AccessToken":"xxxx.x.xxxxx_xxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","RefreshToken":"1/xxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxx","Expiry":"2014-03-16T13:57:58.955387075Z","Extra":null}
   306  team_drive = xxxxxxxxxxxxxxxxxxxx
   307  --------------------
   308  y) Yes this is OK
   309  e) Edit this remote
   310  d) Delete this remote
   311  y/e/d> y
   312  ```
   313  
   314  ### --fast-list ###
   315  
   316  This remote supports `--fast-list` which allows you to use fewer
   317  transactions in exchange for more memory. See the [rclone
   318  docs](/docs/#fast-list) for more details.
   319  
   320  It does this by combining multiple `list` calls into a single API request.
   321  
   322  This works by combining many `'%s' in parents` filters into one expression.
   323  To list the contents of directories a, b and c, the following requests will be send by the regular `List` function:
   324  ```
   325  trashed=false and 'a' in parents
   326  trashed=false and 'b' in parents
   327  trashed=false and 'c' in parents
   328  ```
   329  These can now be combined into a single request:
   330  ```
   331  trashed=false and ('a' in parents or 'b' in parents or 'c' in parents)
   332  ```
   333  
   334  The implementation of `ListR` will put up to 50 `parents` filters into one request.
   335  It will  use the `--checkers` value to specify the number of requests to run in parallel.
   336  
   337  In tests, these batch requests were up to 20x faster than the regular method.
   338  Running the following command against different sized folders gives:
   339  ```
   340  rclone lsjson -vv -R --checkers=6 gdrive:folder
   341  ```
   342  
   343  small folder (220 directories, 700 files):
   344  
   345  - without `--fast-list`: 38s
   346  - with `--fast-list`: 10s
   347  
   348  large folder (10600 directories, 39000 files):
   349  
   350  - without `--fast-list`: 22:05 min
   351  - with `--fast-list`: 58s
   352  
   353  ### Modified time ###
   354  
   355  Google drive stores modification times accurate to 1 ms.
   356  
   357  #### Restricted filename characters
   358  
   359  Only Invalid UTF-8 bytes will be [replaced](/overview/#invalid-utf8),
   360  as they can't be used in JSON strings.
   361  
   362  In contrast to other backends, `/` can also be used in names and `.`
   363  or `..` are valid names.
   364  
   365  ### Revisions ###
   366  
   367  Google drive stores revisions of files.  When you upload a change to
   368  an existing file to google drive using rclone it will create a new
   369  revision of that file.
   370  
   371  Revisions follow the standard google policy which at time of writing
   372  was
   373  
   374    * They are deleted after 30 days or 100 revisions (whatever comes first).
   375    * They do not count towards a user storage quota.
   376  
   377  ### Deleting files ###
   378  
   379  By default rclone will send all files to the trash when deleting
   380  files.  If deleting them permanently is required then use the
   381  `--drive-use-trash=false` flag, or set the equivalent environment
   382  variable.
   383  
   384  ### Shortcuts ###
   385  
   386  In March 2020 Google introduced a new feature in Google Drive called
   387  [drive shortcuts](https://support.google.com/drive/answer/9700156)
   388  ([API](https://developers.google.com/drive/api/v3/shortcuts)). These
   389  will (by September 2020) [replace the ability for files or folders to
   390  be in multiple folders at once](https://cloud.google.com/blog/products/g-suite/simplifying-google-drives-folder-structure-and-sharing-models).
   391  
   392  Shortcuts are files that link to other files on Google Drive somewhat
   393  like a symlink in unix, except they point to the underlying file data
   394  (eg the inode in unix terms) so they don't break if the source is
   395  renamed or moved about.
   396  
   397  Be default rclone treats these as follows.
   398  
   399  For shortcuts pointing to files:
   400  
   401  - When listing a file shortcut appears as the destination file.
   402  - When downloading the contents of the destination file is downloaded.
   403  - When updating shortcut file with a non shortcut file, the shortcut is removed then a new file is uploaded in place of the shortcut.
   404  - When server side moving (renaming) the shortcut is renamed, not the destination file.
   405  - When server side copying the shortcut is copied, not the contents of the shortcut.
   406  - When deleting the shortcut is deleted not the linked file.
   407  - When setting the modification time, the modification time of the linked file will be set.
   408  
   409  For shortcuts pointing to folders:
   410  
   411  - When listing the shortcut appears as a folder and that folder will contain the contents of the linked folder appear (including any sub folders)
   412  - When downloading the contents of the linked folder and sub contents are downloaded
   413  - When uploading to a shortcut folder the file will be placed in the linked folder
   414  - When server side moving (renaming) the shortcut is renamed, not the destination folder
   415  - When server side copying the contents of the linked folder is copied, not the shortcut.
   416  - When deleting with `rclone rmdir` or `rclone purge` the shortcut is deleted not the linked folder.
   417  - **NB** When deleting with `rclone remove` or `rclone mount` the contents of the linked folder will be deleted.
   418  
   419  The [rclone backend](https://rclone.org/commands/rclone_backend/) command can be used to create shortcuts.  
   420  
   421  Shortcuts can be completely ignored with the `--drive-skip-shortcuts` flag
   422  or the corresponding `skip_shortcuts` configuration setting.
   423  
   424  ### Emptying trash ###
   425  
   426  If you wish to empty your trash you can use the `rclone cleanup remote:`
   427  command which will permanently delete all your trashed files. This command
   428  does not take any path arguments.
   429  
   430  Note that Google Drive takes some time (minutes to days) to empty the
   431  trash even though the command returns within a few seconds.  No output
   432  is echoed, so there will be no confirmation even using -v or -vv.
   433  
   434  ### Quota information ###
   435  
   436  To view your current quota you can use the `rclone about remote:`
   437  command which will display your usage limit (quota), the usage in Google
   438  Drive, the size of all files in the Trash and the space used by other
   439  Google services such as Gmail. This command does not take any path
   440  arguments.
   441  
   442  #### Import/Export of google documents ####
   443  
   444  Google documents can be exported from and uploaded to Google Drive.
   445  
   446  When rclone downloads a Google doc it chooses a format to download
   447  depending upon the `--drive-export-formats` setting.
   448  By default the export formats are `docx,xlsx,pptx,svg` which are a
   449  sensible default for an editable document.
   450  
   451  When choosing a format, rclone runs down the list provided in order
   452  and chooses the first file format the doc can be exported as from the
   453  list. If the file can't be exported to a format on the formats list,
   454  then rclone will choose a format from the default list.
   455  
   456  If you prefer an archive copy then you might use `--drive-export-formats
   457  pdf`, or if you prefer openoffice/libreoffice formats you might use
   458  `--drive-export-formats ods,odt,odp`.
   459  
   460  Note that rclone adds the extension to the google doc, so if it is
   461  called `My Spreadsheet` on google docs, it will be exported as `My
   462  Spreadsheet.xlsx` or `My Spreadsheet.pdf` etc.
   463  
   464  When importing files into Google Drive, rclone will convert all
   465  files with an extension in `--drive-import-formats` to their
   466  associated document type.
   467  rclone will not convert any files by default, since the conversion
   468  is lossy process.
   469  
   470  The conversion must result in a file with the same extension when
   471  the `--drive-export-formats` rules are applied to the uploaded document.
   472  
   473  Here are some examples for allowed and prohibited conversions.
   474  
   475  | export-formats | import-formats | Upload Ext | Document Ext | Allowed |
   476  | -------------- | -------------- | ---------- | ------------ | ------- |
   477  | odt | odt | odt | odt | Yes |
   478  | odt | docx,odt | odt | odt | Yes |
   479  |  | docx | docx | docx | Yes |
   480  |  | odt | odt | docx | No |
   481  | odt,docx | docx,odt | docx | odt | No |
   482  | docx,odt | docx,odt | docx | docx | Yes |
   483  | docx,odt | docx,odt | odt | docx | No |
   484  
   485  This limitation can be disabled by specifying `--drive-allow-import-name-change`.
   486  When using this flag, rclone can convert multiple files types resulting
   487  in the same document type at once, eg with `--drive-import-formats docx,odt,txt`,
   488  all files having these extension would result in a document represented as a docx file.
   489  This brings the additional risk of overwriting a document, if multiple files
   490  have the same stem. Many rclone operations will not handle this name change
   491  in any way. They assume an equal name when copying files and might copy the
   492  file again or delete them when the name changes. 
   493  
   494  Here are the possible export extensions with their corresponding mime types.
   495  Most of these can also be used for importing, but there more that are not
   496  listed here. Some of these additional ones might only be available when
   497  the operating system provides the correct MIME type entries.
   498  
   499  This list can be changed by Google Drive at any time and might not
   500  represent the currently available conversions.
   501  
   502  | Extension | Mime Type | Description |
   503  | --------- |-----------| ------------|
   504  | csv  | text/csv | Standard CSV format for Spreadsheets |
   505  | docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | Microsoft Office Document |
   506  | epub | application/epub+zip | E-book format |
   507  | html | text/html | An HTML Document |
   508  | jpg  | image/jpeg | A JPEG Image File |
   509  | json | application/vnd.google-apps.script+json | JSON Text Format |
   510  | odp  | application/vnd.oasis.opendocument.presentation | Openoffice Presentation |
   511  | ods  | application/vnd.oasis.opendocument.spreadsheet | Openoffice Spreadsheet |
   512  | ods  | application/x-vnd.oasis.opendocument.spreadsheet | Openoffice Spreadsheet |
   513  | odt  | application/vnd.oasis.opendocument.text | Openoffice Document |
   514  | pdf  | application/pdf | Adobe PDF Format |
   515  | png  | image/png | PNG Image Format|
   516  | pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation | Microsoft Office Powerpoint |
   517  | rtf  | application/rtf | Rich Text Format |
   518  | svg  | image/svg+xml | Scalable Vector Graphics Format |
   519  | tsv  | text/tab-separated-values | Standard TSV format for spreadsheets |
   520  | txt  | text/plain | Plain Text |
   521  | xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | Microsoft Office Spreadsheet |
   522  | zip  | application/zip | A ZIP file of HTML, Images CSS |
   523  
   524  Google documents can also be exported as link files. These files will
   525  open a browser window for the Google Docs website of that document
   526  when opened. The link file extension has to be specified as a
   527  `--drive-export-formats` parameter. They will match all available
   528  Google Documents.
   529  
   530  | Extension | Description | OS Support |
   531  | --------- | ----------- | ---------- |
   532  | desktop | freedesktop.org specified desktop entry | Linux |
   533  | link.html | An HTML Document with a redirect | All |
   534  | url | INI style link file | macOS, Windows |
   535  | webloc | macOS specific XML format | macOS |
   536  
   537  {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/drive/drive.go then run make backenddocs" >}}
   538  ### Standard Options
   539  
   540  Here are the standard options specific to drive (Google Drive).
   541  
   542  #### --drive-client-id
   543  
   544  Google Application Client Id
   545  Setting your own is recommended.
   546  See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
   547  If you leave this blank, it will use an internal key which is low performance.
   548  
   549  - Config:      client_id
   550  - Env Var:     RCLONE_DRIVE_CLIENT_ID
   551  - Type:        string
   552  - Default:     ""
   553  
   554  #### --drive-client-secret
   555  
   556  Google Application Client Secret
   557  Setting your own is recommended.
   558  
   559  - Config:      client_secret
   560  - Env Var:     RCLONE_DRIVE_CLIENT_SECRET
   561  - Type:        string
   562  - Default:     ""
   563  
   564  #### --drive-scope
   565  
   566  Scope that rclone should use when requesting access from drive.
   567  
   568  - Config:      scope
   569  - Env Var:     RCLONE_DRIVE_SCOPE
   570  - Type:        string
   571  - Default:     ""
   572  - Examples:
   573      - "drive"
   574          - Full access all files, excluding Application Data Folder.
   575      - "drive.readonly"
   576          - Read-only access to file metadata and file contents.
   577      - "drive.file"
   578          - Access to files created by rclone only.
   579          - These are visible in the drive website.
   580          - File authorization is revoked when the user deauthorizes the app.
   581      - "drive.appfolder"
   582          - Allows read and write access to the Application Data folder.
   583          - This is not visible in the drive website.
   584      - "drive.metadata.readonly"
   585          - Allows read-only access to file metadata but
   586          - does not allow any access to read or download file content.
   587  
   588  #### --drive-root-folder-id
   589  
   590  ID of the root folder
   591  Leave blank normally.
   592  
   593  Fill in to access "Computers" folders (see docs), or for rclone to use
   594  a non root folder as its starting point.
   595  
   596  Note that if this is blank, the first time rclone runs it will fill it
   597  in with the ID of the root folder.
   598  
   599  
   600  - Config:      root_folder_id
   601  - Env Var:     RCLONE_DRIVE_ROOT_FOLDER_ID
   602  - Type:        string
   603  - Default:     ""
   604  
   605  #### --drive-service-account-file
   606  
   607  Service Account Credentials JSON file path 
   608  Leave blank normally.
   609  Needed only if you want use SA instead of interactive login.
   610  
   611  - Config:      service_account_file
   612  - Env Var:     RCLONE_DRIVE_SERVICE_ACCOUNT_FILE
   613  - Type:        string
   614  - Default:     ""
   615  
   616  ### Advanced Options
   617  
   618  Here are the advanced options specific to drive (Google Drive).
   619  
   620  #### --drive-service-account-credentials
   621  
   622  Service Account Credentials JSON blob
   623  Leave blank normally.
   624  Needed only if you want use SA instead of interactive login.
   625  
   626  - Config:      service_account_credentials
   627  - Env Var:     RCLONE_DRIVE_SERVICE_ACCOUNT_CREDENTIALS
   628  - Type:        string
   629  - Default:     ""
   630  
   631  #### --drive-team-drive
   632  
   633  ID of the Team Drive
   634  
   635  - Config:      team_drive
   636  - Env Var:     RCLONE_DRIVE_TEAM_DRIVE
   637  - Type:        string
   638  - Default:     ""
   639  
   640  #### --drive-auth-owner-only
   641  
   642  Only consider files owned by the authenticated user.
   643  
   644  - Config:      auth_owner_only
   645  - Env Var:     RCLONE_DRIVE_AUTH_OWNER_ONLY
   646  - Type:        bool
   647  - Default:     false
   648  
   649  #### --drive-use-trash
   650  
   651  Send files to the trash instead of deleting permanently.
   652  Defaults to true, namely sending files to the trash.
   653  Use `--drive-use-trash=false` to delete files permanently instead.
   654  
   655  - Config:      use_trash
   656  - Env Var:     RCLONE_DRIVE_USE_TRASH
   657  - Type:        bool
   658  - Default:     true
   659  
   660  #### --drive-skip-gdocs
   661  
   662  Skip google documents in all listings.
   663  If given, gdocs practically become invisible to rclone.
   664  
   665  - Config:      skip_gdocs
   666  - Env Var:     RCLONE_DRIVE_SKIP_GDOCS
   667  - Type:        bool
   668  - Default:     false
   669  
   670  #### --drive-skip-checksum-gphotos
   671  
   672  Skip MD5 checksum on Google photos and videos only.
   673  
   674  Use this if you get checksum errors when transferring Google photos or
   675  videos.
   676  
   677  Setting this flag will cause Google photos and videos to return a
   678  blank MD5 checksum.
   679  
   680  Google photos are identified by being in the "photos" space.
   681  
   682  Corrupted checksums are caused by Google modifying the image/video but
   683  not updating the checksum.
   684  
   685  - Config:      skip_checksum_gphotos
   686  - Env Var:     RCLONE_DRIVE_SKIP_CHECKSUM_GPHOTOS
   687  - Type:        bool
   688  - Default:     false
   689  
   690  #### --drive-shared-with-me
   691  
   692  Only show files that are shared with me.
   693  
   694  Instructs rclone to operate on your "Shared with me" folder (where
   695  Google Drive lets you access the files and folders others have shared
   696  with you).
   697  
   698  This works both with the "list" (lsd, lsl, etc) and the "copy"
   699  commands (copy, sync, etc), and with all other commands too.
   700  
   701  - Config:      shared_with_me
   702  - Env Var:     RCLONE_DRIVE_SHARED_WITH_ME
   703  - Type:        bool
   704  - Default:     false
   705  
   706  #### --drive-trashed-only
   707  
   708  Only show files that are in the trash.
   709  This will show trashed files in their original directory structure.
   710  
   711  - Config:      trashed_only
   712  - Env Var:     RCLONE_DRIVE_TRASHED_ONLY
   713  - Type:        bool
   714  - Default:     false
   715  
   716  #### --drive-formats
   717  
   718  Deprecated: see export_formats
   719  
   720  - Config:      formats
   721  - Env Var:     RCLONE_DRIVE_FORMATS
   722  - Type:        string
   723  - Default:     ""
   724  
   725  #### --drive-export-formats
   726  
   727  Comma separated list of preferred formats for downloading Google docs.
   728  
   729  - Config:      export_formats
   730  - Env Var:     RCLONE_DRIVE_EXPORT_FORMATS
   731  - Type:        string
   732  - Default:     "docx,xlsx,pptx,svg"
   733  
   734  #### --drive-import-formats
   735  
   736  Comma separated list of preferred formats for uploading Google docs.
   737  
   738  - Config:      import_formats
   739  - Env Var:     RCLONE_DRIVE_IMPORT_FORMATS
   740  - Type:        string
   741  - Default:     ""
   742  
   743  #### --drive-allow-import-name-change
   744  
   745  Allow the filetype to change when uploading Google docs (e.g. file.doc to file.docx). This will confuse sync and reupload every time.
   746  
   747  - Config:      allow_import_name_change
   748  - Env Var:     RCLONE_DRIVE_ALLOW_IMPORT_NAME_CHANGE
   749  - Type:        bool
   750  - Default:     false
   751  
   752  #### --drive-use-created-date
   753  
   754  Use file created date instead of modified date.,
   755  
   756  Useful when downloading data and you want the creation date used in
   757  place of the last modified date.
   758  
   759  **WARNING**: This flag may have some unexpected consequences.
   760  
   761  When uploading to your drive all files will be overwritten unless they
   762  haven't been modified since their creation. And the inverse will occur
   763  while downloading.  This side effect can be avoided by using the
   764  "--checksum" flag.
   765  
   766  This feature was implemented to retain photos capture date as recorded
   767  by google photos. You will first need to check the "Create a Google
   768  Photos folder" option in your google drive settings. You can then copy
   769  or move the photos locally and use the date the image was taken
   770  (created) set as the modification date.
   771  
   772  - Config:      use_created_date
   773  - Env Var:     RCLONE_DRIVE_USE_CREATED_DATE
   774  - Type:        bool
   775  - Default:     false
   776  
   777  #### --drive-use-shared-date
   778  
   779  Use date file was shared instead of modified date.
   780  
   781  Note that, as with "--drive-use-created-date", this flag may have
   782  unexpected consequences when uploading/downloading files.
   783  
   784  If both this flag and "--drive-use-created-date" are set, the created
   785  date is used.
   786  
   787  - Config:      use_shared_date
   788  - Env Var:     RCLONE_DRIVE_USE_SHARED_DATE
   789  - Type:        bool
   790  - Default:     false
   791  
   792  #### --drive-list-chunk
   793  
   794  Size of listing chunk 100-1000. 0 to disable.
   795  
   796  - Config:      list_chunk
   797  - Env Var:     RCLONE_DRIVE_LIST_CHUNK
   798  - Type:        int
   799  - Default:     1000
   800  
   801  #### --drive-impersonate
   802  
   803  Impersonate this user when using a service account.
   804  
   805  Note that if this is used then "root_folder_id" will be ignored.
   806  
   807  
   808  - Config:      impersonate
   809  - Env Var:     RCLONE_DRIVE_IMPERSONATE
   810  - Type:        string
   811  - Default:     ""
   812  
   813  #### --drive-alternate-export
   814  
   815  Use alternate export URLs for google documents export.,
   816  
   817  If this option is set this instructs rclone to use an alternate set of
   818  export URLs for drive documents.  Users have reported that the
   819  official export URLs can't export large documents, whereas these
   820  unofficial ones can.
   821  
   822  See rclone issue [#2243](https://github.com/rclone/rclone/issues/2243) for background,
   823  [this google drive issue](https://issuetracker.google.com/issues/36761333) and
   824  [this helpful post](https://www.labnol.org/internet/direct-links-for-google-drive/28356/).
   825  
   826  - Config:      alternate_export
   827  - Env Var:     RCLONE_DRIVE_ALTERNATE_EXPORT
   828  - Type:        bool
   829  - Default:     false
   830  
   831  #### --drive-upload-cutoff
   832  
   833  Cutoff for switching to chunked upload
   834  
   835  - Config:      upload_cutoff
   836  - Env Var:     RCLONE_DRIVE_UPLOAD_CUTOFF
   837  - Type:        SizeSuffix
   838  - Default:     8M
   839  
   840  #### --drive-chunk-size
   841  
   842  Upload chunk size. Must a power of 2 >= 256k.
   843  
   844  Making this larger will improve performance, but note that each chunk
   845  is buffered in memory one per transfer.
   846  
   847  Reducing this will reduce memory usage but decrease performance.
   848  
   849  - Config:      chunk_size
   850  - Env Var:     RCLONE_DRIVE_CHUNK_SIZE
   851  - Type:        SizeSuffix
   852  - Default:     8M
   853  
   854  #### --drive-acknowledge-abuse
   855  
   856  Set to allow files which return cannotDownloadAbusiveFile to be downloaded.
   857  
   858  If downloading a file returns the error "This file has been identified
   859  as malware or spam and cannot be downloaded" with the error code
   860  "cannotDownloadAbusiveFile" then supply this flag to rclone to
   861  indicate you acknowledge the risks of downloading the file and rclone
   862  will download it anyway.
   863  
   864  - Config:      acknowledge_abuse
   865  - Env Var:     RCLONE_DRIVE_ACKNOWLEDGE_ABUSE
   866  - Type:        bool
   867  - Default:     false
   868  
   869  #### --drive-keep-revision-forever
   870  
   871  Keep new head revision of each file forever.
   872  
   873  - Config:      keep_revision_forever
   874  - Env Var:     RCLONE_DRIVE_KEEP_REVISION_FOREVER
   875  - Type:        bool
   876  - Default:     false
   877  
   878  #### --drive-size-as-quota
   879  
   880  Show sizes as storage quota usage, not actual size.
   881  
   882  Show the size of a file as the storage quota used. This is the
   883  current version plus any older versions that have been set to keep
   884  forever.
   885  
   886  **WARNING**: This flag may have some unexpected consequences.
   887  
   888  It is not recommended to set this flag in your config - the
   889  recommended usage is using the flag form --drive-size-as-quota when
   890  doing rclone ls/lsl/lsf/lsjson/etc only.
   891  
   892  If you do use this flag for syncing (not recommended) then you will
   893  need to use --ignore size also.
   894  
   895  - Config:      size_as_quota
   896  - Env Var:     RCLONE_DRIVE_SIZE_AS_QUOTA
   897  - Type:        bool
   898  - Default:     false
   899  
   900  #### --drive-v2-download-min-size
   901  
   902  If Object's are greater, use drive v2 API to download.
   903  
   904  - Config:      v2_download_min_size
   905  - Env Var:     RCLONE_DRIVE_V2_DOWNLOAD_MIN_SIZE
   906  - Type:        SizeSuffix
   907  - Default:     off
   908  
   909  #### --drive-pacer-min-sleep
   910  
   911  Minimum time to sleep between API calls.
   912  
   913  - Config:      pacer_min_sleep
   914  - Env Var:     RCLONE_DRIVE_PACER_MIN_SLEEP
   915  - Type:        Duration
   916  - Default:     100ms
   917  
   918  #### --drive-pacer-burst
   919  
   920  Number of API calls to allow without sleeping.
   921  
   922  - Config:      pacer_burst
   923  - Env Var:     RCLONE_DRIVE_PACER_BURST
   924  - Type:        int
   925  - Default:     100
   926  
   927  #### --drive-server-side-across-configs
   928  
   929  Allow server side operations (eg copy) to work across different drive configs.
   930  
   931  This can be useful if you wish to do a server side copy between two
   932  different Google drives.  Note that this isn't enabled by default
   933  because it isn't easy to tell if it will work between any two
   934  configurations.
   935  
   936  - Config:      server_side_across_configs
   937  - Env Var:     RCLONE_DRIVE_SERVER_SIDE_ACROSS_CONFIGS
   938  - Type:        bool
   939  - Default:     false
   940  
   941  #### --drive-disable-http2
   942  
   943  Disable drive using http2
   944  
   945  There is currently an unsolved issue with the google drive backend and
   946  HTTP/2.  HTTP/2 is therefore disabled by default for the drive backend
   947  but can be re-enabled here.  When the issue is solved this flag will
   948  be removed.
   949  
   950  See: https://github.com/rclone/rclone/issues/3631
   951  
   952  
   953  
   954  - Config:      disable_http2
   955  - Env Var:     RCLONE_DRIVE_DISABLE_HTTP2
   956  - Type:        bool
   957  - Default:     true
   958  
   959  #### --drive-stop-on-upload-limit
   960  
   961  Make upload limit errors be fatal
   962  
   963  At the time of writing it is only possible to upload 750GB of data to
   964  Google Drive a day (this is an undocumented limit). When this limit is
   965  reached Google Drive produces a slightly different error message. When
   966  this flag is set it causes these errors to be fatal.  These will stop
   967  the in-progress sync.
   968  
   969  Note that this detection is relying on error message strings which
   970  Google don't document so it may break in the future.
   971  
   972  See: https://github.com/rclone/rclone/issues/3857
   973  
   974  
   975  - Config:      stop_on_upload_limit
   976  - Env Var:     RCLONE_DRIVE_STOP_ON_UPLOAD_LIMIT
   977  - Type:        bool
   978  - Default:     false
   979  
   980  #### --drive-skip-shortcuts
   981  
   982  If set skip shortcut files
   983  
   984  Normally rclone dereferences shortcut files making them appear as if
   985  they are the original file (see [the shortcuts section](#shortcuts)).
   986  If this flag is set then rclone will ignore shortcut files completely.
   987  
   988  
   989  - Config:      skip_shortcuts
   990  - Env Var:     RCLONE_DRIVE_SKIP_SHORTCUTS
   991  - Type:        bool
   992  - Default:     false
   993  
   994  #### --drive-encoding
   995  
   996  This sets the encoding for the backend.
   997  
   998  See: the [encoding section in the overview](/overview/#encoding) for more info.
   999  
  1000  - Config:      encoding
  1001  - Env Var:     RCLONE_DRIVE_ENCODING
  1002  - Type:        MultiEncoder
  1003  - Default:     InvalidUtf8
  1004  
  1005  ### Backend commands
  1006  
  1007  Here are the commands specific to the drive backend.
  1008  
  1009  Run them with
  1010  
  1011      rclone backend COMMAND remote:
  1012  
  1013  The help below will explain what arguments each command takes.
  1014  
  1015  See [the "rclone backend" command](/commands/rclone_backend/) for more
  1016  info on how to pass options and arguments.
  1017  
  1018  These can be run on a running backend using the rc command
  1019  [backend/command](/rc/#backend/command).
  1020  
  1021  #### get
  1022  
  1023  Get command for fetching the drive config parameters
  1024  
  1025      rclone backend get remote: [options] [<arguments>+]
  1026  
  1027  This is a get command which will be used to fetch the various drive config parameters
  1028  
  1029  Usage Examples:
  1030  
  1031      rclone backend get drive: [-o service_account_file] [-o chunk_size]
  1032      rclone rc backend/command command=get fs=drive: [-o service_account_file] [-o chunk_size]
  1033  
  1034  
  1035  Options:
  1036  
  1037  - "chunk_size": show the current upload chunk size
  1038  - "service_account_file": show the current service account file
  1039  
  1040  #### set
  1041  
  1042  Set command for updating the drive config parameters
  1043  
  1044      rclone backend set remote: [options] [<arguments>+]
  1045  
  1046  This is a set command which will be used to update the various drive config parameters
  1047  
  1048  Usage Examples:
  1049  
  1050      rclone backend set drive: [-o service_account_file=sa.json] [-o chunk_size=67108864]
  1051      rclone rc backend/command command=set fs=drive: [-o service_account_file=sa.json] [-o chunk_size=67108864]
  1052  
  1053  
  1054  Options:
  1055  
  1056  - "chunk_size": update the current upload chunk size
  1057  - "service_account_file": update the current service account file
  1058  
  1059  #### shortcut
  1060  
  1061  Create shortcuts from files or directories
  1062  
  1063      rclone backend shortcut remote: [options] [<arguments>+]
  1064  
  1065  This command creates shortcuts from files or directories.
  1066  
  1067  Usage:
  1068  
  1069      rclone backend shortcut drive: source_item destination_shortcut
  1070      rclone backend shortcut drive: source_item -o target=drive2: destination_shortcut
  1071  
  1072  In the first example this creates a shortcut from the "source_item"
  1073  which can be a file or a directory to the "destination_shortcut". The
  1074  "source_item" and the "destination_shortcut" should be relative paths
  1075  from "drive:"
  1076  
  1077  In the second example this creates a shortcut from the "source_item"
  1078  relative to "drive:" to the "destination_shortcut" relative to
  1079  "drive2:". This may fail with a permission error if the user
  1080  authenticated with "drive2:" can't read files from "drive:".
  1081  
  1082  
  1083  Options:
  1084  
  1085  - "target": optional target remote for the shortcut destination
  1086  
  1087  {{< rem autogenerated options stop >}}
  1088  
  1089  ### Limitations ###
  1090  
  1091  Drive has quite a lot of rate limiting.  This causes rclone to be
  1092  limited to transferring about 2 files per second only.  Individual
  1093  files may be transferred much faster at 100s of MBytes/s but lots of
  1094  small files can take a long time.
  1095  
  1096  Server side copies are also subject to a separate rate limit. If you
  1097  see User rate limit exceeded errors, wait at least 24 hours and retry.
  1098  You can disable server side copies with `--disable copy` to download
  1099  and upload the files if you prefer.
  1100  
  1101  #### Limitations of Google Docs ####
  1102  
  1103  Google docs will appear as size -1 in `rclone ls` and as size 0 in
  1104  anything which uses the VFS layer, eg `rclone mount`, `rclone serve`.
  1105  
  1106  This is because rclone can't find out the size of the Google docs
  1107  without downloading them.
  1108  
  1109  Google docs will transfer correctly with `rclone sync`, `rclone copy`
  1110  etc as rclone knows to ignore the size when doing the transfer.
  1111  
  1112  However an unfortunate consequence of this is that you may not be able
  1113  to download Google docs using `rclone mount`. If it doesn't work you
  1114  will get a 0 sized file.  If you try again the doc may gain its
  1115  correct size and be downloadable. Whether it will work on not depends
  1116  on the application accessing the mount and the OS you are running -
  1117  experiment to find out if it does work for you!
  1118  
  1119  ### Duplicated files ###
  1120  
  1121  Sometimes, for no reason I've been able to track down, drive will
  1122  duplicate a file that rclone uploads.  Drive unlike all the other
  1123  remotes can have duplicated files.
  1124  
  1125  Duplicated files cause problems with the syncing and you will see
  1126  messages in the log about duplicates.
  1127  
  1128  Use `rclone dedupe` to fix duplicated files.
  1129  
  1130  Note that this isn't just a problem with rclone, even Google Photos on
  1131  Android duplicates files on drive sometimes.
  1132  
  1133  ### Rclone appears to be re-copying files it shouldn't ###
  1134  
  1135  The most likely cause of this is the duplicated file issue above - run
  1136  `rclone dedupe` and check your logs for duplicate object or directory
  1137  messages.
  1138  
  1139  This can also be caused by a delay/caching on google drive's end when
  1140  comparing directory listings. Specifically with team drives used in
  1141  combination with --fast-list. Files that were uploaded recently may
  1142  not appear on the directory list sent to rclone when using --fast-list.
  1143  
  1144  Waiting a moderate period of time between attempts (estimated to be
  1145  approximately 1 hour) and/or not using --fast-list both seem to be
  1146  effective in preventing the problem.
  1147  
  1148  ### Making your own client_id ###
  1149  
  1150  When you use rclone with Google drive in its default configuration you
  1151  are using rclone's client_id.  This is shared between all the rclone
  1152  users.  There is a global rate limit on the number of queries per
  1153  second that each client_id can do set by Google.  rclone already has a
  1154  high quota and I will continue to make sure it is high enough by
  1155  contacting Google.
  1156  
  1157  It is strongly recommended to use your own client ID as the default rclone ID is heavily used. If you have multiple services running, it is recommended to use an API key for each service. The default Google quota is 10 transactions per second so it is recommended to stay under that number as if you use more than that, it will cause rclone to rate limit and make things slower.
  1158  
  1159  Here is how to create your own Google Drive client ID for rclone:
  1160  
  1161  1. Log into the [Google API
  1162  Console](https://console.developers.google.com/) with your Google
  1163  account. It doesn't matter what Google account you use. (It need not
  1164  be the same account as the Google Drive you want to access)
  1165  
  1166  2. Select a project or create a new project.
  1167  
  1168  3. Under "ENABLE APIS AND SERVICES" search for "Drive", and enable the
  1169  "Google Drive API".
  1170  
  1171  4. Click "Credentials" in the left-side panel (not "Create
  1172  credentials", which opens the wizard), then "Create credentials"
  1173  
  1174  5. If you already configured an "Oauth Consent Screen", then skip
  1175  to the next step; if not, click on "CONFIGURE CONSENT SCREEN" button 
  1176  (near the top right corner of the right panel), then select "External"
  1177  and click on "CREATE"; on the next screen, enter an "Application name"
  1178  ("rclone" is OK) then click on "Save" (all other data is optional). 
  1179  Click again on "Credentials" on the left panel to go back to the 
  1180  "Credentials" screen.
  1181  
  1182  (PS: if you are a GSuite user, you could also select "Internal" instead
  1183  of "External" above, but this has not been tested/documented so far). 
  1184  
  1185  6.  Click on the "+ CREATE CREDENTIALS" button at the top of the screen,
  1186  then select "OAuth client ID".
  1187  
  1188  7. Choose an application type of "Desktop app" if you using a Google account or "Other" if 
  1189  you using a GSuite account and click "Create". (the default name is fine)
  1190  
  1191  8. It will show you a client ID and client secret.  Use these values
  1192  in rclone config to add a new remote or edit an existing remote.
  1193  
  1194  Be aware that, due to the "enhanced security" recently introduced by
  1195  Google, you are theoretically expected to "submit your app for verification"
  1196  and then wait a few weeks(!) for their response; in practice, you can go right
  1197  ahead and use the client ID and client secret with rclone, the only issue will
  1198  be a very scary confirmation screen shown when you connect via your browser 
  1199  for rclone to be able to get its token-id (but as this only happens during 
  1200  the remote configuration, it's not such a big deal). 
  1201  
  1202  (Thanks to @balazer on github for these instructions.)