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

     1  ---
     2  title: "Remote Control / API"
     3  description: "Remote controlling rclone with its API"
     4  ---
     5  
     6  # Remote controlling rclone with its API
     7  
     8  If rclone is run with the `--rc` flag then it starts an http server
     9  which can be used to remote control rclone using its API.
    10  
    11  If you just want to run a remote control then see the [rcd command](/commands/rclone_rcd/).
    12  
    13  ## Supported parameters
    14  
    15  ### --rc
    16  
    17  Flag to start the http server listen on remote requests
    18        
    19  ### --rc-addr=IP
    20  
    21  IPaddress:Port or :Port to bind server to. (default "localhost:5572")
    22  
    23  ### --rc-cert=KEY
    24  SSL PEM key (concatenation of certificate and CA certificate)
    25  
    26  ### --rc-client-ca=PATH
    27  Client certificate authority to verify clients with
    28  
    29  ### --rc-htpasswd=PATH
    30  
    31  htpasswd file - if not provided no authentication is done
    32  
    33  ### --rc-key=PATH
    34  
    35  SSL PEM Private key
    36  
    37  ### --rc-max-header-bytes=VALUE
    38  
    39  Maximum size of request header (default 4096)
    40  
    41  ### --rc-user=VALUE
    42  
    43  User name for authentication.
    44  
    45  ### --rc-pass=VALUE
    46  
    47  Password for authentication.
    48  
    49  ### --rc-realm=VALUE
    50  
    51  Realm for authentication (default "rclone")
    52  
    53  ### --rc-server-read-timeout=DURATION
    54  
    55  Timeout for server reading data (default 1h0m0s)
    56  
    57  ### --rc-server-write-timeout=DURATION
    58  
    59  Timeout for server writing data (default 1h0m0s)
    60  
    61  ### --rc-serve
    62  
    63  Enable the serving of remote objects via the HTTP interface.  This
    64  means objects will be accessible at http://127.0.0.1:5572/ by default,
    65  so you can browse to http://127.0.0.1:5572/ or http://127.0.0.1:5572/*
    66  to see a listing of the remotes.  Objects may be requested from
    67  remotes using this syntax http://127.0.0.1:5572/[remote:path]/path/to/object
    68  
    69  Default Off.
    70  
    71  ### --rc-files /path/to/directory
    72  
    73  Path to local files to serve on the HTTP server.
    74  
    75  If this is set then rclone will serve the files in that directory.  It
    76  will also open the root in the web browser if specified.  This is for
    77  implementing browser based GUIs for rclone functions.
    78  
    79  If `--rc-user` or `--rc-pass` is set then the URL that is opened will
    80  have the authorization in the URL in the `http://user:pass@localhost/`
    81  style.
    82  
    83  Default Off.
    84  
    85  ### --rc-enable-metrics
    86  
    87  Enable OpenMetrics/Prometheus compatible endpoint at `/metrics`.
    88  
    89  Default Off.
    90  
    91  ### --rc-web-gui
    92  
    93  Set this flag to serve the default web gui on the same port as rclone.
    94  
    95  Default Off.
    96  
    97  ### --rc-allow-origin
    98  
    99  Set the allowed Access-Control-Allow-Origin for rc requests.
   100  
   101  Can be used with --rc-web-gui if the rclone is running on different IP than the web-gui.
   102  
   103  Default is IP address on which rc is running.
   104  
   105  ### --rc-web-fetch-url
   106  
   107  Set the URL to fetch the rclone-web-gui files from.
   108  
   109  Default https://api.github.com/repos/rclone/rclone-webui-react/releases/latest.
   110  
   111  ### --rc-web-gui-update
   112  
   113  Set this flag to check and update rclone-webui-react from the rc-web-fetch-url.
   114  
   115  Default Off.
   116  
   117  ### --rc-web-gui-force-update
   118  
   119  Set this flag to force update rclone-webui-react from the rc-web-fetch-url.
   120  
   121  Default Off.
   122  
   123  ### --rc-web-gui-no-open-browser
   124  
   125  Set this flag to disable opening browser automatically when using web-gui.
   126  
   127  Default Off.
   128  
   129  ### --rc-job-expire-duration=DURATION
   130  
   131  Expire finished async jobs older than DURATION (default 60s).
   132  
   133  ### --rc-job-expire-interval=DURATION
   134  
   135  Interval duration to check for expired async jobs (default 10s).
   136  
   137  ### --rc-no-auth
   138  
   139  By default rclone will require authorisation to have been set up on
   140  the rc interface in order to use any methods which access any rclone
   141  remotes.  Eg `operations/list` is denied as it involved creating a
   142  remote as is `sync/copy`.
   143  
   144  If this is set then no authorisation will be required on the server to
   145  use these methods.  The alternative is to use `--rc-user` and
   146  `--rc-pass` and use these credentials in the request.
   147  
   148  Default Off.
   149  
   150  ## Accessing the remote control via the rclone rc command
   151  
   152  Rclone itself implements the remote control protocol in its `rclone
   153  rc` command.
   154  
   155  You can use it like this
   156  
   157  ```
   158  $ rclone rc rc/noop param1=one param2=two
   159  {
   160  	"param1": "one",
   161  	"param2": "two"
   162  }
   163  ```
   164  
   165  Run `rclone rc` on its own to see the help for the installed remote
   166  control commands.
   167  
   168  `rclone rc` also supports a `--json` flag which can be used to send
   169  more complicated input parameters.
   170  
   171  ```
   172  $ rclone rc --json '{ "p1": [1,"2",null,4], "p2": { "a":1, "b":2 } }' rc/noop
   173  {
   174  	"p1": [
   175  		1,
   176  		"2",
   177  		null,
   178  		4
   179  	],
   180  	"p2": {
   181  		"a": 1,
   182  		"b": 2
   183  	}
   184  }
   185  ```
   186  
   187  ## Special parameters
   188  
   189  The rc interface supports some special parameters which apply to
   190  **all** commands.  These start with `_` to show they are different.
   191  
   192  ### Running asynchronous jobs with _async = true
   193  
   194  Each rc call is classified as a job and it is assigned its own id. By default
   195  jobs are executed immediately as they are created or synchronously.
   196  
   197  If `_async` has a true value when supplied to an rc call then it will
   198  return immediately with a job id and the task will be run in the
   199  background.  The `job/status` call can be used to get information of
   200  the background job.  The job can be queried for up to 1 minute after
   201  it has finished.
   202  
   203  It is recommended that potentially long running jobs, eg `sync/sync`,
   204  `sync/copy`, `sync/move`, `operations/purge` are run with the `_async`
   205  flag to avoid any potential problems with the HTTP request and
   206  response timing out.
   207  
   208  Starting a job with the `_async` flag:
   209  
   210  ```
   211  $ rclone rc --json '{ "p1": [1,"2",null,4], "p2": { "a":1, "b":2 }, "_async": true }' rc/noop
   212  {
   213  	"jobid": 2
   214  }
   215  ```
   216  
   217  Query the status to see if the job has finished.  For more information
   218  on the meaning of these return parameters see the `job/status` call.
   219  
   220  ```
   221  $ rclone rc --json '{ "jobid":2 }' job/status
   222  {
   223  	"duration": 0.000124163,
   224  	"endTime": "2018-10-27T11:38:07.911245881+01:00",
   225  	"error": "",
   226  	"finished": true,
   227  	"id": 2,
   228  	"output": {
   229  		"_async": true,
   230  		"p1": [
   231  			1,
   232  			"2",
   233  			null,
   234  			4
   235  		],
   236  		"p2": {
   237  			"a": 1,
   238  			"b": 2
   239  		}
   240  	},
   241  	"startTime": "2018-10-27T11:38:07.911121728+01:00",
   242  	"success": true
   243  }
   244  ```
   245  
   246  `job/list` can be used to show the running or recently completed jobs
   247  
   248  ```
   249  $ rclone rc job/list
   250  {
   251  	"jobids": [
   252  		2
   253  	]
   254  }
   255  ```
   256  
   257  ### Assigning operations to groups with _group = value
   258  
   259  Each rc call has its own stats group for tracking its metrics. By default
   260  grouping is done by the composite group name from prefix `job/` and  id of the
   261  job like so `job/1`.
   262  
   263  If `_group` has a value then stats for that request will be grouped under that
   264  value. This allows caller to group stats under their own name.
   265  
   266  Stats for specific group can be accessed by passing `group` to `core/stats`:
   267  
   268  ```
   269  $ rclone rc --json '{ "group": "job/1" }' core/stats
   270  {
   271  	"speed": 12345
   272  	...
   273  }
   274  ```
   275  
   276  ## Supported commands
   277  {{< rem autogenerated start "- run make rcdocs - don't edit here" >}}
   278  ### backend/command: Runs a backend command. {#backend-command}
   279  
   280  This takes the following parameters
   281  
   282  - command - a string with the command name
   283  - fs - a remote name string eg "drive:"
   284  - arg - a list of arguments for the backend command
   285  - opt - a map of string to string of options
   286  
   287  Returns
   288  
   289  - result - result from the backend command
   290  
   291  For example
   292  
   293      rclone rc backend/command command=noop fs=. -o echo=yes -o blue -a path1 -a path2
   294  
   295  Returns
   296  
   297  ```
   298  {
   299  	"result": {
   300  		"arg": [
   301  			"path1",
   302  			"path2"
   303  		],
   304  		"name": "noop",
   305  		"opt": {
   306  			"blue": "",
   307  			"echo": "yes"
   308  		}
   309  	}
   310  }
   311  ```
   312  
   313  Note that this is the direct equivalent of using this "backend"
   314  command:
   315  
   316      rclone backend noop . -o echo=yes -o blue path1 path2
   317  
   318  Note that arguments must be preceded by the "-a" flag
   319  
   320  See the [backend](/commands/rclone_backend/) command for more information.
   321  
   322  **Authentication is required for this call.**
   323  
   324  ### cache/expire: Purge a remote from cache {#cache-expire}
   325  
   326  Purge a remote from the cache backend. Supports either a directory or a file.
   327  Params:
   328    - remote = path to remote (required)
   329    - withData = true/false to delete cached data (chunks) as well (optional)
   330  
   331  Eg
   332  
   333      rclone rc cache/expire remote=path/to/sub/folder/
   334      rclone rc cache/expire remote=/ withData=true
   335  
   336  ### cache/fetch: Fetch file chunks {#cache-fetch}
   337  
   338  Ensure the specified file chunks are cached on disk.
   339  
   340  The chunks= parameter specifies the file chunks to check.
   341  It takes a comma separated list of array slice indices.
   342  The slice indices are similar to Python slices: start[:end]
   343  
   344  start is the 0 based chunk number from the beginning of the file
   345  to fetch inclusive. end is 0 based chunk number from the beginning
   346  of the file to fetch exclusive.
   347  Both values can be negative, in which case they count from the back
   348  of the file. The value "-5:" represents the last 5 chunks of a file.
   349  
   350  Some valid examples are:
   351  ":5,-5:" -> the first and last five chunks
   352  "0,-2" -> the first and the second last chunk
   353  "0:10" -> the first ten chunks
   354  
   355  Any parameter with a key that starts with "file" can be used to
   356  specify files to fetch, eg
   357  
   358      rclone rc cache/fetch chunks=0 file=hello file2=home/goodbye
   359  
   360  File names will automatically be encrypted when the a crypt remote
   361  is used on top of the cache.
   362  
   363  ### cache/stats: Get cache stats {#cache-stats}
   364  
   365  Show statistics for the cache remote.
   366  
   367  ### config/create: create the config for a remote. {#config-create}
   368  
   369  This takes the following parameters
   370  
   371  - name - name of remote
   372  - parameters - a map of \{ "key": "value" \} pairs
   373  - type - type of the new remote
   374  - obscure - optional bool - forces obscuring of passwords
   375  - noObscure - optional bool - forces passwords not to be obscured
   376  
   377  
   378  See the [config create command](/commands/rclone_config_create/) command for more information on the above.
   379  
   380  **Authentication is required for this call.**
   381  
   382  ### config/delete: Delete a remote in the config file. {#config-delete}
   383  
   384  Parameters:
   385  
   386  - name - name of remote to delete
   387  
   388  See the [config delete command](/commands/rclone_config_delete/) command for more information on the above.
   389  
   390  **Authentication is required for this call.**
   391  
   392  ### config/dump: Dumps the config file. {#config-dump}
   393  
   394  Returns a JSON object:
   395  - key: value
   396  
   397  Where keys are remote names and values are the config parameters.
   398  
   399  See the [config dump command](/commands/rclone_config_dump/) command for more information on the above.
   400  
   401  **Authentication is required for this call.**
   402  
   403  ### config/get: Get a remote in the config file. {#config-get}
   404  
   405  Parameters:
   406  
   407  - name - name of remote to get
   408  
   409  See the [config dump command](/commands/rclone_config_dump/) command for more information on the above.
   410  
   411  **Authentication is required for this call.**
   412  
   413  ### config/listremotes: Lists the remotes in the config file. {#config-listremotes}
   414  
   415  Returns
   416  - remotes - array of remote names
   417  
   418  See the [listremotes command](/commands/rclone_listremotes/) command for more information on the above.
   419  
   420  **Authentication is required for this call.**
   421  
   422  ### config/password: password the config for a remote. {#config-password}
   423  
   424  This takes the following parameters
   425  
   426  - name - name of remote
   427  - parameters - a map of \{ "key": "value" \} pairs
   428  
   429  
   430  See the [config password command](/commands/rclone_config_password/) command for more information on the above.
   431  
   432  **Authentication is required for this call.**
   433  
   434  ### config/providers: Shows how providers are configured in the config file. {#config-providers}
   435  
   436  Returns a JSON object:
   437  - providers - array of objects
   438  
   439  See the [config providers command](/commands/rclone_config_providers/) command for more information on the above.
   440  
   441  **Authentication is required for this call.**
   442  
   443  ### config/update: update the config for a remote. {#config-update}
   444  
   445  This takes the following parameters
   446  
   447  - name - name of remote
   448  - parameters - a map of \{ "key": "value" \} pairs
   449  - obscure - optional bool - forces obscuring of passwords
   450  - noObscure - optional bool - forces passwords not to be obscured
   451  
   452  
   453  See the [config update command](/commands/rclone_config_update/) command for more information on the above.
   454  
   455  **Authentication is required for this call.**
   456  
   457  ### core/bwlimit: Set the bandwidth limit. {#core-bwlimit}
   458  
   459  This sets the bandwidth limit to that passed in.
   460  
   461  Eg
   462  
   463      rclone rc core/bwlimit rate=off
   464      {
   465          "bytesPerSecond": -1,
   466          "rate": "off"
   467      }
   468      rclone rc core/bwlimit rate=1M
   469      {
   470          "bytesPerSecond": 1048576,
   471          "rate": "1M"
   472      }
   473  
   474  
   475  If the rate parameter is not supplied then the bandwidth is queried
   476  
   477      rclone rc core/bwlimit
   478      {
   479          "bytesPerSecond": 1048576,
   480          "rate": "1M"
   481      }
   482  
   483  The format of the parameter is exactly the same as passed to --bwlimit
   484  except only one bandwidth may be specified.
   485  
   486  In either case "rate" is returned as a human readable string, and
   487  "bytesPerSecond" is returned as a number.
   488  
   489  ### core/gc: Runs a garbage collection. {#core-gc}
   490  
   491  This tells the go runtime to do a garbage collection run.  It isn't
   492  necessary to call this normally, but it can be useful for debugging
   493  memory problems.
   494  
   495  ### core/group-list: Returns list of stats. {#core-group-list}
   496  
   497  This returns list of stats groups currently in memory. 
   498  
   499  Returns the following values:
   500  ```
   501  {
   502  	"groups":  an array of group names:
   503  		[
   504  			"group1",
   505  			"group2",
   506  			...
   507  		]
   508  }
   509  ```
   510  
   511  ### core/memstats: Returns the memory statistics {#core-memstats}
   512  
   513  This returns the memory statistics of the running program.  What the values mean
   514  are explained in the go docs: https://golang.org/pkg/runtime/#MemStats
   515  
   516  The most interesting values for most people are:
   517  
   518  * HeapAlloc: This is the amount of memory rclone is actually using
   519  * HeapSys: This is the amount of memory rclone has obtained from the OS
   520  * Sys: this is the total amount of memory requested from the OS
   521    * It is virtual memory so may include unused memory
   522  
   523  ### core/obscure: Obscures a string passed in. {#core-obscure}
   524  
   525  Pass a clear string and rclone will obscure it for the config file:
   526  - clear - string
   527  
   528  Returns
   529  - obscured - string
   530  
   531  ### core/pid: Return PID of current process {#core-pid}
   532  
   533  This returns PID of current process.
   534  Useful for stopping rclone process.
   535  
   536  ### core/quit: Terminates the app. {#core-quit}
   537  
   538  (optional) Pass an exit code to be used for terminating the app:
   539  - exitCode - int
   540  
   541  ### core/stats: Returns stats about current transfers. {#core-stats}
   542  
   543  This returns all available stats:
   544  
   545  	rclone rc core/stats
   546  
   547  If group is not provided then summed up stats for all groups will be
   548  returned.
   549  
   550  Parameters
   551  
   552  - group - name of the stats group (string)
   553  
   554  Returns the following values:
   555  
   556  ```
   557  {
   558  	"speed": average speed in bytes/sec since start of the process,
   559  	"bytes": total transferred bytes since the start of the process,
   560  	"errors": number of errors,
   561  	"fatalError": whether there has been at least one FatalError,
   562  	"retryError": whether there has been at least one non-NoRetryError,
   563  	"checks": number of checked files,
   564  	"transfers": number of transferred files,
   565  	"deletes" : number of deleted files,
   566  	"renames" : number of renamed files,
   567  	"elapsedTime": time in seconds since the start of the process,
   568  	"lastError": last occurred error,
   569  	"transferring": an array of currently active file transfers:
   570  		[
   571  			{
   572  				"bytes": total transferred bytes for this file,
   573  				"eta": estimated time in seconds until file transfer completion
   574  				"name": name of the file,
   575  				"percentage": progress of the file transfer in percent,
   576  				"speed": speed in bytes/sec,
   577  				"speedAvg": speed in bytes/sec as an exponentially weighted moving average,
   578  				"size": size of the file in bytes
   579  			}
   580  		],
   581  	"checking": an array of names of currently active file checks
   582  		[]
   583  }
   584  ```
   585  Values for "transferring", "checking" and "lastError" are only assigned if data is available.
   586  The value for "eta" is null if an eta cannot be determined.
   587  
   588  ### core/stats-delete: Delete stats group. {#core-stats-delete}
   589  
   590  This deletes entire stats group
   591  
   592  Parameters
   593  
   594  - group - name of the stats group (string)
   595  
   596  ### core/stats-reset: Reset stats. {#core-stats-reset}
   597  
   598  This clears counters, errors and finished transfers for all stats or specific 
   599  stats group if group is provided.
   600  
   601  Parameters
   602  
   603  - group - name of the stats group (string)
   604  
   605  ### core/transferred: Returns stats about completed transfers. {#core-transferred}
   606  
   607  This returns stats about completed transfers:
   608  
   609  	rclone rc core/transferred
   610  
   611  If group is not provided then completed transfers for all groups will be
   612  returned.
   613  
   614  Note only the last 100 completed transfers are returned.
   615  
   616  Parameters
   617  
   618  - group - name of the stats group (string)
   619  
   620  Returns the following values:
   621  ```
   622  {
   623  	"transferred":  an array of completed transfers (including failed ones):
   624  		[
   625  			{
   626  				"name": name of the file,
   627  				"size": size of the file in bytes,
   628  				"bytes": total transferred bytes for this file,
   629  				"checked": if the transfer is only checked (skipped, deleted),
   630  				"timestamp": integer representing millisecond unix epoch,
   631  				"error": string description of the error (empty if successful),
   632  				"jobid": id of the job that this transfer belongs to
   633  			}
   634  		]
   635  }
   636  ```
   637  
   638  ### core/version: Shows the current version of rclone and the go runtime. {#core-version}
   639  
   640  This shows the current version of go and the go runtime
   641  
   642  - version - rclone version, eg "v1.44"
   643  - decomposed - version number as [major, minor, patch, subpatch]
   644      - note patch and subpatch will be 999 for a git compiled version
   645  - isGit - boolean - true if this was compiled from the git version
   646  - os - OS in use as according to Go
   647  - arch - cpu architecture in use according to Go
   648  - goVersion - version of Go runtime in use
   649  
   650  ### debug/set-block-profile-rate: Set runtime.SetBlockProfileRate for blocking profiling. {#debug-set-block-profile-rate}
   651  
   652  SetBlockProfileRate controls the fraction of goroutine blocking events
   653  that are reported in the blocking profile. The profiler aims to sample
   654  an average of one blocking event per rate nanoseconds spent blocked.
   655  
   656  To include every blocking event in the profile, pass rate = 1. To turn
   657  off profiling entirely, pass rate <= 0.
   658  
   659  After calling this you can use this to see the blocking profile:
   660  
   661      go tool pprof http://localhost:5572/debug/pprof/block
   662  
   663  Parameters
   664  
   665  - rate - int
   666  
   667  ### debug/set-mutex-profile-fraction: Set runtime.SetMutexProfileFraction for mutex profiling. {#debug-set-mutex-profile-fraction}
   668  
   669  SetMutexProfileFraction controls the fraction of mutex contention
   670  events that are reported in the mutex profile. On average 1/rate
   671  events are reported. The previous rate is returned.
   672  
   673  To turn off profiling entirely, pass rate 0. To just read the current
   674  rate, pass rate < 0. (For n>1 the details of sampling may change.)
   675  
   676  Once this is set you can look use this to profile the mutex contention:
   677  
   678      go tool pprof http://localhost:5572/debug/pprof/mutex
   679  
   680  Parameters
   681  
   682  - rate - int
   683  
   684  Results
   685  
   686  - previousRate - int
   687  
   688  ### job/list: Lists the IDs of the running jobs {#job-list}
   689  
   690  Parameters - None
   691  
   692  Results
   693  
   694  - jobids - array of integer job ids
   695  
   696  ### job/status: Reads the status of the job ID {#job-status}
   697  
   698  Parameters
   699  
   700  - jobid - id of the job (integer)
   701  
   702  Results
   703  
   704  - finished - boolean
   705  - duration - time in seconds that the job ran for
   706  - endTime - time the job finished (eg "2018-10-26T18:50:20.528746884+01:00")
   707  - error - error from the job or empty string for no error
   708  - finished - boolean whether the job has finished or not
   709  - id - as passed in above
   710  - startTime - time the job started (eg "2018-10-26T18:50:20.528336039+01:00")
   711  - success - boolean - true for success false otherwise
   712  - output - output of the job as would have been returned if called synchronously
   713  - progress - output of the progress related to the underlying job
   714  
   715  ### job/stop: Stop the running job {#job-stop}
   716  
   717  Parameters
   718  
   719  - jobid - id of the job (integer)
   720  
   721  ### mount/mount: Create a new mount point {#mount-mount}
   722  
   723  rclone allows Linux, FreeBSD, macOS and Windows to mount any of
   724  Rclone's cloud storage systems as a file system with FUSE.
   725  
   726  If no mountType is provided, the priority is given as follows: 1. mount 2.cmount 3.mount2
   727  
   728  This takes the following parameters
   729  
   730  - fs - a remote path to be mounted (required)
   731  - mountPoint: valid path on the local machine (required)
   732  - mountType: One of the values (mount, cmount, mount2) specifies the mount implementation to use
   733  
   734  Eg
   735  
   736      rclone rc mount/mount fs=mydrive: mountPoint=/home/<user>/mountPoint
   737      rclone rc mount/mount fs=mydrive: mountPoint=/home/<user>/mountPoint mountType=mount
   738  
   739  **Authentication is required for this call.**
   740  
   741  ### mount/types: Show all possible mount types {#mount-types}
   742  
   743  This shows all possible mount types and returns them as a list.
   744  
   745  This takes no parameters and returns
   746  
   747  - mountTypes: list of mount types
   748  
   749  The mount types are strings like "mount", "mount2", "cmount" and can
   750  be passed to mount/mount as the mountType parameter.
   751  
   752  Eg
   753  
   754      rclone rc mount/types
   755  
   756  **Authentication is required for this call.**
   757  
   758  ### mount/unmount: Unmount all active mounts {#mount-unmount}
   759  
   760  rclone allows Linux, FreeBSD, macOS and Windows to
   761  mount any of Rclone's cloud storage systems as a file system with
   762  FUSE.
   763  
   764  This takes the following parameters
   765  
   766  - mountPoint: valid path on the local machine where the mount was created (required)
   767  
   768  Eg
   769  
   770      rclone rc mount/unmount mountPoint=/home/<user>/mountPoint
   771  
   772  **Authentication is required for this call.**
   773  
   774  ### operations/about: Return the space used on the remote {#operations-about}
   775  
   776  This takes the following parameters
   777  
   778  - fs - a remote name string eg "drive:"
   779  
   780  The result is as returned from rclone about --json
   781  
   782  See the [about command](/commands/rclone_size/) command for more information on the above.
   783  
   784  **Authentication is required for this call.**
   785  
   786  ### operations/cleanup: Remove trashed files in the remote or path {#operations-cleanup}
   787  
   788  This takes the following parameters
   789  
   790  - fs - a remote name string eg "drive:"
   791  
   792  See the [cleanup command](/commands/rclone_cleanup/) command for more information on the above.
   793  
   794  **Authentication is required for this call.**
   795  
   796  ### operations/copyfile: Copy a file from source remote to destination remote {#operations-copyfile}
   797  
   798  This takes the following parameters
   799  
   800  - srcFs - a remote name string eg "drive:" for the source
   801  - srcRemote - a path within that remote eg "file.txt" for the source
   802  - dstFs - a remote name string eg "drive2:" for the destination
   803  - dstRemote - a path within that remote eg "file2.txt" for the destination
   804  
   805  **Authentication is required for this call.**
   806  
   807  ### operations/copyurl: Copy the URL to the object {#operations-copyurl}
   808  
   809  This takes the following parameters
   810  
   811  - fs - a remote name string eg "drive:"
   812  - remote - a path within that remote eg "dir"
   813  - url - string, URL to read from
   814   - autoFilename - boolean, set to true to retrieve destination file name from url
   815  See the [copyurl command](/commands/rclone_copyurl/) command for more information on the above.
   816  
   817  **Authentication is required for this call.**
   818  
   819  ### operations/delete: Remove files in the path {#operations-delete}
   820  
   821  This takes the following parameters
   822  
   823  - fs - a remote name string eg "drive:"
   824  
   825  See the [delete command](/commands/rclone_delete/) command for more information on the above.
   826  
   827  **Authentication is required for this call.**
   828  
   829  ### operations/deletefile: Remove the single file pointed to {#operations-deletefile}
   830  
   831  This takes the following parameters
   832  
   833  - fs - a remote name string eg "drive:"
   834  - remote - a path within that remote eg "dir"
   835  
   836  See the [deletefile command](/commands/rclone_deletefile/) command for more information on the above.
   837  
   838  **Authentication is required for this call.**
   839  
   840  ### operations/fsinfo: Return information about the remote {#operations-fsinfo}
   841  
   842  This takes the following parameters
   843  
   844  - fs - a remote name string eg "drive:"
   845  
   846  This returns info about the remote passed in;
   847  
   848  ```
   849  {
   850  	// optional features and whether they are available or not
   851  	"Features": {
   852  		"About": true,
   853  		"BucketBased": false,
   854  		"CanHaveEmptyDirectories": true,
   855  		"CaseInsensitive": false,
   856  		"ChangeNotify": false,
   857  		"CleanUp": false,
   858  		"Copy": false,
   859  		"DirCacheFlush": false,
   860  		"DirMove": true,
   861  		"DuplicateFiles": false,
   862  		"GetTier": false,
   863  		"ListR": false,
   864  		"MergeDirs": false,
   865  		"Move": true,
   866  		"OpenWriterAt": true,
   867  		"PublicLink": false,
   868  		"Purge": true,
   869  		"PutStream": true,
   870  		"PutUnchecked": false,
   871  		"ReadMimeType": false,
   872  		"ServerSideAcrossConfigs": false,
   873  		"SetTier": false,
   874  		"SetWrapper": false,
   875  		"UnWrap": false,
   876  		"WrapFs": false,
   877  		"WriteMimeType": false
   878  	},
   879  	// Names of hashes available
   880  	"Hashes": [
   881  		"MD5",
   882  		"SHA-1",
   883  		"DropboxHash",
   884  		"QuickXorHash"
   885  	],
   886  	"Name": "local",	// Name as created
   887  	"Precision": 1,		// Precision of timestamps in ns
   888  	"Root": "/",		// Path as created
   889  	"String": "Local file system at /" // how the remote will appear in logs
   890  }
   891  ```
   892  
   893  This command does not have a command line equivalent so use this instead:
   894  
   895      rclone rc --loopback operations/fsinfo fs=remote:
   896  
   897  ### operations/list: List the given remote and path in JSON format {#operations-list}
   898  
   899  This takes the following parameters
   900  
   901  - fs - a remote name string eg "drive:"
   902  - remote - a path within that remote eg "dir"
   903  - opt - a dictionary of options to control the listing (optional)
   904      - recurse - If set recurse directories
   905      - noModTime - If set return modification time
   906      - showEncrypted -  If set show decrypted names
   907      - showOrigIDs - If set show the IDs for each item if known
   908      - showHash - If set return a dictionary of hashes
   909  
   910  The result is
   911  
   912  - list
   913      - This is an array of objects as described in the lsjson command
   914  
   915  See the [lsjson command](/commands/rclone_lsjson/) for more information on the above and examples.
   916  
   917  **Authentication is required for this call.**
   918  
   919  ### operations/mkdir: Make a destination directory or container {#operations-mkdir}
   920  
   921  This takes the following parameters
   922  
   923  - fs - a remote name string eg "drive:"
   924  - remote - a path within that remote eg "dir"
   925  
   926  See the [mkdir command](/commands/rclone_mkdir/) command for more information on the above.
   927  
   928  **Authentication is required for this call.**
   929  
   930  ### operations/movefile: Move a file from source remote to destination remote {#operations-movefile}
   931  
   932  This takes the following parameters
   933  
   934  - srcFs - a remote name string eg "drive:" for the source
   935  - srcRemote - a path within that remote eg "file.txt" for the source
   936  - dstFs - a remote name string eg "drive2:" for the destination
   937  - dstRemote - a path within that remote eg "file2.txt" for the destination
   938  
   939  **Authentication is required for this call.**
   940  
   941  ### operations/publiclink: Create or retrieve a public link to the given file or folder. {#operations-publiclink}
   942  
   943  This takes the following parameters
   944  
   945  - fs - a remote name string eg "drive:"
   946  - remote - a path within that remote eg "dir"
   947  
   948  Returns
   949  
   950  - url - URL of the resource
   951  
   952  See the [link command](/commands/rclone_link/) command for more information on the above.
   953  
   954  **Authentication is required for this call.**
   955  
   956  ### operations/purge: Remove a directory or container and all of its contents {#operations-purge}
   957  
   958  This takes the following parameters
   959  
   960  - fs - a remote name string eg "drive:"
   961  - remote - a path within that remote eg "dir"
   962  
   963  See the [purge command](/commands/rclone_purge/) command for more information on the above.
   964  
   965  **Authentication is required for this call.**
   966  
   967  ### operations/rmdir: Remove an empty directory or container {#operations-rmdir}
   968  
   969  This takes the following parameters
   970  
   971  - fs - a remote name string eg "drive:"
   972  - remote - a path within that remote eg "dir"
   973  
   974  See the [rmdir command](/commands/rclone_rmdir/) command for more information on the above.
   975  
   976  **Authentication is required for this call.**
   977  
   978  ### operations/rmdirs: Remove all the empty directories in the path {#operations-rmdirs}
   979  
   980  This takes the following parameters
   981  
   982  - fs - a remote name string eg "drive:"
   983  - remote - a path within that remote eg "dir"
   984  - leaveRoot - boolean, set to true not to delete the root
   985  
   986  See the [rmdirs command](/commands/rclone_rmdirs/) command for more information on the above.
   987  
   988  **Authentication is required for this call.**
   989  
   990  ### operations/size: Count the number of bytes and files in remote {#operations-size}
   991  
   992  This takes the following parameters
   993  
   994  - fs - a remote name string eg "drive:path/to/dir"
   995  
   996  Returns
   997  
   998  - count - number of files
   999  - bytes - number of bytes in those files
  1000  
  1001  See the [size command](/commands/rclone_size/) command for more information on the above.
  1002  
  1003  **Authentication is required for this call.**
  1004  
  1005  ### options/blocks: List all the option blocks {#options-blocks}
  1006  
  1007  Returns
  1008  - options - a list of the options block names
  1009  
  1010  ### options/get: Get all the options {#options-get}
  1011  
  1012  Returns an object where keys are option block names and values are an
  1013  object with the current option values in.
  1014  
  1015  This shows the internal names of the option within rclone which should
  1016  map to the external options very easily with a few exceptions.
  1017  
  1018  ### options/set: Set an option {#options-set}
  1019  
  1020  Parameters
  1021  
  1022  - option block name containing an object with
  1023    - key: value
  1024  
  1025  Repeated as often as required.
  1026  
  1027  Only supply the options you wish to change.  If an option is unknown
  1028  it will be silently ignored.  Not all options will have an effect when
  1029  changed like this.
  1030  
  1031  For example:
  1032  
  1033  This sets DEBUG level logs (-vv)
  1034  
  1035      rclone rc options/set --json '{"main": {"LogLevel": 8}}'
  1036  
  1037  And this sets INFO level logs (-v)
  1038  
  1039      rclone rc options/set --json '{"main": {"LogLevel": 7}}'
  1040  
  1041  And this sets NOTICE level logs (normal without -v)
  1042  
  1043      rclone rc options/set --json '{"main": {"LogLevel": 6}}'
  1044  
  1045  ### rc/error: This returns an error {#rc-error}
  1046  
  1047  This returns an error with the input as part of its error string.
  1048  Useful for testing error handling.
  1049  
  1050  ### rc/list: List all the registered remote control commands {#rc-list}
  1051  
  1052  This lists all the registered remote control commands as a JSON map in
  1053  the commands response.
  1054  
  1055  ### rc/noop: Echo the input to the output parameters {#rc-noop}
  1056  
  1057  This echoes the input parameters to the output parameters for testing
  1058  purposes.  It can be used to check that rclone is still alive and to
  1059  check that parameter passing is working properly.
  1060  
  1061  ### rc/noopauth: Echo the input to the output parameters requiring auth {#rc-noopauth}
  1062  
  1063  This echoes the input parameters to the output parameters for testing
  1064  purposes.  It can be used to check that rclone is still alive and to
  1065  check that parameter passing is working properly.
  1066  
  1067  **Authentication is required for this call.**
  1068  
  1069  ### sync/copy: copy a directory from source remote to destination remote {#sync-copy}
  1070  
  1071  This takes the following parameters
  1072  
  1073  - srcFs - a remote name string eg "drive:src" for the source
  1074  - dstFs - a remote name string eg "drive:dst" for the destination
  1075  
  1076  
  1077  See the [copy command](/commands/rclone_copy/) command for more information on the above.
  1078  
  1079  **Authentication is required for this call.**
  1080  
  1081  ### sync/move: move a directory from source remote to destination remote {#sync-move}
  1082  
  1083  This takes the following parameters
  1084  
  1085  - srcFs - a remote name string eg "drive:src" for the source
  1086  - dstFs - a remote name string eg "drive:dst" for the destination
  1087  - deleteEmptySrcDirs - delete empty src directories if set
  1088  
  1089  
  1090  See the [move command](/commands/rclone_move/) command for more information on the above.
  1091  
  1092  **Authentication is required for this call.**
  1093  
  1094  ### sync/sync: sync a directory from source remote to destination remote {#sync-sync}
  1095  
  1096  This takes the following parameters
  1097  
  1098  - srcFs - a remote name string eg "drive:src" for the source
  1099  - dstFs - a remote name string eg "drive:dst" for the destination
  1100  
  1101  
  1102  See the [sync command](/commands/rclone_sync/) command for more information on the above.
  1103  
  1104  **Authentication is required for this call.**
  1105  
  1106  ### vfs/forget: Forget files or directories in the directory cache. {#vfs-forget}
  1107  
  1108  This forgets the paths in the directory cache causing them to be
  1109  re-read from the remote when needed.
  1110  
  1111  If no paths are passed in then it will forget all the paths in the
  1112  directory cache.
  1113  
  1114      rclone rc vfs/forget
  1115  
  1116  Otherwise pass files or dirs in as file=path or dir=path.  Any
  1117  parameter key starting with file will forget that file and any
  1118  starting with dir will forget that dir, eg
  1119  
  1120      rclone rc vfs/forget file=hello file2=goodbye dir=home/junk
  1121  
  1122  ### vfs/poll-interval: Get the status or update the value of the poll-interval option. {#vfs-poll-interval}
  1123  
  1124  Without any parameter given this returns the current status of the
  1125  poll-interval setting.
  1126  
  1127  When the interval=duration parameter is set, the poll-interval value
  1128  is updated and the polling function is notified.
  1129  Setting interval=0 disables poll-interval.
  1130  
  1131      rclone rc vfs/poll-interval interval=5m
  1132  
  1133  The timeout=duration parameter can be used to specify a time to wait
  1134  for the current poll function to apply the new value.
  1135  If timeout is less or equal 0, which is the default, wait indefinitely.
  1136  
  1137  The new poll-interval value will only be active when the timeout is
  1138  not reached.
  1139  
  1140  If poll-interval is updated or disabled temporarily, some changes
  1141  might not get picked up by the polling function, depending on the
  1142  used remote.
  1143  
  1144  ### vfs/refresh: Refresh the directory cache. {#vfs-refresh}
  1145  
  1146  This reads the directories for the specified paths and freshens the
  1147  directory cache.
  1148  
  1149  If no paths are passed in then it will refresh the root directory.
  1150  
  1151      rclone rc vfs/refresh
  1152  
  1153  Otherwise pass directories in as dir=path. Any parameter key
  1154  starting with dir will refresh that directory, eg
  1155  
  1156      rclone rc vfs/refresh dir=home/junk dir2=data/misc
  1157  
  1158  If the parameter recursive=true is given the whole directory tree
  1159  will get refreshed. This refresh will use --fast-list if enabled.
  1160  
  1161  {{< rem autogenerated stop >}}
  1162  
  1163  ## Accessing the remote control via HTTP
  1164  
  1165  Rclone implements a simple HTTP based protocol.
  1166  
  1167  Each endpoint takes an JSON object and returns a JSON object or an
  1168  error.  The JSON objects are essentially a map of string names to
  1169  values.
  1170  
  1171  All calls must made using POST.
  1172  
  1173  The input objects can be supplied using URL parameters, POST
  1174  parameters or by supplying "Content-Type: application/json" and a JSON
  1175  blob in the body.  There are examples of these below using `curl`.
  1176  
  1177  The response will be a JSON blob in the body of the response.  This is
  1178  formatted to be reasonably human readable.
  1179  
  1180  ### Error returns
  1181  
  1182  If an error occurs then there will be an HTTP error status (eg 500)
  1183  and the body of the response will contain a JSON encoded error object,
  1184  eg
  1185  
  1186  ```
  1187  {
  1188      "error": "Expecting string value for key \"remote\" (was float64)",
  1189      "input": {
  1190          "fs": "/tmp",
  1191          "remote": 3
  1192      },
  1193      "status": 400
  1194      "path": "operations/rmdir",
  1195  }
  1196  ```
  1197  
  1198  The keys in the error response are
  1199  - error - error string
  1200  - input - the input parameters to the call
  1201  - status - the HTTP status code
  1202  - path - the path of the call
  1203  
  1204  ### CORS
  1205  
  1206  The sever implements basic CORS support and allows all origins for that.
  1207  The response to a preflight OPTIONS request will echo the requested "Access-Control-Request-Headers" back.
  1208  
  1209  ### Using POST with URL parameters only
  1210  
  1211  ```
  1212  curl -X POST 'http://localhost:5572/rc/noop?potato=1&sausage=2'
  1213  ```
  1214  
  1215  Response
  1216  
  1217  ```
  1218  {
  1219  	"potato": "1",
  1220  	"sausage": "2"
  1221  }
  1222  ```
  1223  
  1224  Here is what an error response looks like:
  1225  
  1226  ```
  1227  curl -X POST 'http://localhost:5572/rc/error?potato=1&sausage=2'
  1228  ```
  1229  
  1230  ```
  1231  {
  1232  	"error": "arbitrary error on input map[potato:1 sausage:2]",
  1233  	"input": {
  1234  		"potato": "1",
  1235  		"sausage": "2"
  1236  	}
  1237  }
  1238  ```
  1239  
  1240  Note that curl doesn't return errors to the shell unless you use the `-f` option
  1241  
  1242  ```
  1243  $ curl -f -X POST 'http://localhost:5572/rc/error?potato=1&sausage=2'
  1244  curl: (22) The requested URL returned error: 400 Bad Request
  1245  $ echo $?
  1246  22
  1247  ```
  1248  
  1249  ### Using POST with a form
  1250  
  1251  ```
  1252  curl --data "potato=1" --data "sausage=2" http://localhost:5572/rc/noop
  1253  ```
  1254  
  1255  Response
  1256  
  1257  ```
  1258  {
  1259  	"potato": "1",
  1260  	"sausage": "2"
  1261  }
  1262  ```
  1263  
  1264  Note that you can combine these with URL parameters too with the POST
  1265  parameters taking precedence.
  1266  
  1267  ```
  1268  curl --data "potato=1" --data "sausage=2" "http://localhost:5572/rc/noop?rutabaga=3&sausage=4"
  1269  ```
  1270  
  1271  Response
  1272  
  1273  ```
  1274  {
  1275  	"potato": "1",
  1276  	"rutabaga": "3",
  1277  	"sausage": "4"
  1278  }
  1279  
  1280  ```
  1281  
  1282  ### Using POST with a JSON blob
  1283  
  1284  ```
  1285  curl -H "Content-Type: application/json" -X POST -d '{"potato":2,"sausage":1}' http://localhost:5572/rc/noop
  1286  ```
  1287  
  1288  response
  1289  
  1290  ```
  1291  {
  1292  	"password": "xyz",
  1293  	"username": "xyz"
  1294  }
  1295  ```
  1296  
  1297  This can be combined with URL parameters too if required.  The JSON
  1298  blob takes precedence.
  1299  
  1300  ```
  1301  curl -H "Content-Type: application/json" -X POST -d '{"potato":2,"sausage":1}' 'http://localhost:5572/rc/noop?rutabaga=3&potato=4'
  1302  ```
  1303  
  1304  ```
  1305  {
  1306  	"potato": 2,
  1307  	"rutabaga": "3",
  1308  	"sausage": 1
  1309  }
  1310  ```
  1311  
  1312  ## Debugging rclone with pprof ##
  1313  
  1314  If you use the `--rc` flag this will also enable the use of the go
  1315  profiling tools on the same port.
  1316  
  1317  To use these, first [install go](https://golang.org/doc/install).
  1318  
  1319  ### Debugging memory use
  1320  
  1321  To profile rclone's memory use you can run:
  1322  
  1323      go tool pprof -web http://localhost:5572/debug/pprof/heap
  1324  
  1325  This should open a page in your browser showing what is using what
  1326  memory.
  1327  
  1328  You can also use the `-text` flag to produce a textual summary
  1329  
  1330  ```
  1331  $ go tool pprof -text http://localhost:5572/debug/pprof/heap
  1332  Showing nodes accounting for 1537.03kB, 100% of 1537.03kB total
  1333        flat  flat%   sum%        cum   cum%
  1334   1024.03kB 66.62% 66.62%  1024.03kB 66.62%  github.com/rclone/rclone/vendor/golang.org/x/net/http2/hpack.addDecoderNode
  1335       513kB 33.38%   100%      513kB 33.38%  net/http.newBufioWriterSize
  1336           0     0%   100%  1024.03kB 66.62%  github.com/rclone/rclone/cmd/all.init
  1337           0     0%   100%  1024.03kB 66.62%  github.com/rclone/rclone/cmd/serve.init
  1338           0     0%   100%  1024.03kB 66.62%  github.com/rclone/rclone/cmd/serve/restic.init
  1339           0     0%   100%  1024.03kB 66.62%  github.com/rclone/rclone/vendor/golang.org/x/net/http2.init
  1340           0     0%   100%  1024.03kB 66.62%  github.com/rclone/rclone/vendor/golang.org/x/net/http2/hpack.init
  1341           0     0%   100%  1024.03kB 66.62%  github.com/rclone/rclone/vendor/golang.org/x/net/http2/hpack.init.0
  1342           0     0%   100%  1024.03kB 66.62%  main.init
  1343           0     0%   100%      513kB 33.38%  net/http.(*conn).readRequest
  1344           0     0%   100%      513kB 33.38%  net/http.(*conn).serve
  1345           0     0%   100%  1024.03kB 66.62%  runtime.main
  1346  ```
  1347  
  1348  ### Debugging go routine leaks
  1349  
  1350  Memory leaks are most often caused by go routine leaks keeping memory
  1351  alive which should have been garbage collected.
  1352  
  1353  See all active go routines using
  1354  
  1355      curl http://localhost:5572/debug/pprof/goroutine?debug=1
  1356  
  1357  Or go to http://localhost:5572/debug/pprof/goroutine?debug=1 in your browser.
  1358  
  1359  ### Other profiles to look at
  1360  
  1361  You can see a summary of profiles available at http://localhost:5572/debug/pprof/
  1362  
  1363  Here is how to use some of them:
  1364  
  1365  - Memory: `go tool pprof http://localhost:5572/debug/pprof/heap`
  1366  - Go routines: `curl http://localhost:5572/debug/pprof/goroutine?debug=1`
  1367  - 30-second CPU profile: `go tool pprof http://localhost:5572/debug/pprof/profile`
  1368  - 5-second execution trace: `wget http://localhost:5572/debug/pprof/trace?seconds=5`
  1369  - Goroutine blocking profile
  1370      - Enable first with: `rclone rc debug/set-block-profile-rate rate=1` ([docs](#debug/set-block-profile-rate))
  1371      - `go tool pprof http://localhost:5572/debug/pprof/block`
  1372  - Contended mutexes:
  1373      - Enable first with: `rclone rc debug/set-mutex-profile-fraction rate=1` ([docs](#debug/set-mutex-profile-fraction))
  1374      - `go tool pprof http://localhost:5572/debug/pprof/mutex`
  1375  
  1376  See the [net/http/pprof docs](https://golang.org/pkg/net/http/pprof/)
  1377  for more info on how to use the profiling and for a general overview
  1378  see [the Go team's blog post on profiling go programs](https://blog.golang.org/profiling-go-programs).
  1379  
  1380  The profiling hook is [zero overhead unless it is used](https://stackoverflow.com/q/26545159/164234).
  1381