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