github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/docs/content/union.md (about) 1 --- 2 title: "Union" 3 description: "Remote Unification" 4 --- 5 6 {{< icon "fa fa-link" >}} Union 7 ----------------------------------------- 8 9 The `union` remote provides a unification similar to UnionFS using other remotes. 10 11 Paths may be as deep as required or a local path, 12 eg `remote:directory/subdirectory` or `/directory/subdirectory`. 13 14 During the initial setup with `rclone config` you will specify the upstream 15 remotes as a space separated list. The upstream remotes can either be a local paths or other remotes. 16 17 Attribute `:ro` and `:nc` can be attach to the end of path to tag the remote as **read only** or **no create**, 18 eg `remote:directory/subdirectory:ro` or `remote:directory/subdirectory:nc`. 19 20 Subfolders can be used in upstream remotes. Assume a union remote named `backup` 21 with the remotes `mydrive:private/backup`. Invoking `rclone mkdir backup:desktop` 22 is exactly the same as invoking `rclone mkdir mydrive2:/backup/desktop`. 23 24 There will be no special handling of paths containing `..` segments. 25 Invoking `rclone mkdir backup:../desktop` is exactly the same as invoking 26 `rclone mkdir mydrive2:/backup/../desktop`. 27 28 ### Behavior / Policies 29 30 The behavior of union backend is inspired by [trapexit/mergerfs](https://github.com/trapexit/mergerfs). All functions are grouped into 3 categories: **action**, **create** and **search**. These functions and categories can be assigned a policy which dictates what file or directory is chosen when performing that behavior. Any policy can be assigned to a function or category though some may not be very useful in practice. For instance: **rand** (random) may be useful for file creation (create) but could lead to very odd behavior if used for `delete` if there were more than one copy of the file. 31 32 #### Function / Category classifications 33 34 | Category | Description | Functions | 35 |----------|--------------------------|-------------------------------------------------------------------------------------| 36 | action | Writing Existing file | move, rmdir, rmdirs, delete, purge and copy, sync (as destination when file exist) | 37 | create | Create non-existing file | copy, sync (as destination when file not exist) | 38 | search | Reading and listing file | ls, lsd, lsl, cat, md5sum, sha1sum and copy, sync (as source) | 39 | N/A | | size, about | 40 41 #### Path Preservation 42 43 Policies, as described below, are of two basic types. `path preserving` and `non-path preserving`. 44 45 All policies which start with `ep` (**epff**, **eplfs**, **eplus**, **epmfs**, **eprand**) are `path preserving`. `ep` stands for `existing path`. 46 47 A path preserving policy will only consider upstreams where the relative path being accessed already exists. 48 49 When using non-path preserving policies paths will be created in target upstreams as necessary. 50 51 #### Quota Relevant Policies 52 53 Some policies rely on quota information. These policies should be used only if your upstreams support the respective quota fields. 54 55 | Policy | Required Field | 56 |------------|----------------| 57 | lfs, eplfs | Free | 58 | mfs, epmfs | Free | 59 | lus, eplus | Used | 60 | lno, eplno | Objects | 61 62 To check if your upstream supports the field, run `rclone about remote: [flags]` and see if the required field exists. 63 64 #### Filters 65 66 Policies basically search upstream remotes and create a list of files / paths for functions to work on. The policy is responsible for filtering and sorting. The policy type defines the sorting but filtering is mostly uniform as described below. 67 68 * No **search** policies filter. 69 * All **action** policies will filter out remotes which are tagged as **read-only**. 70 * All **create** policies will filter out remotes which are tagged **read-only** or **no-create**. 71 72 If all remotes are filtered an error will be returned. 73 74 #### Policy descriptions 75 76 The policies definition are inspired by [trapexit/mergerfs](https://github.com/trapexit/mergerfs) but not exactly the same. Some policy definition could be different due to the much larger latency of remote file systems. 77 78 | Policy | Description | 79 |------------------|------------------------------------------------------------| 80 | all | Search category: same as **epall**. Action category: same as **epall**. Create category: act on all upstreams. | 81 | epall (existing path, all) | Search category: Given this order configured, act on the first one found where the relative path exists. Action category: apply to all found. Create category: act on all upstreams where the relative path exists. | 82 | epff (existing path, first found) | Act on the first one found, by the time upstreams reply, where the relative path exists. | 83 | eplfs (existing path, least free space) | Of all the upstreams on which the relative path exists choose the one with the least free space. | 84 | eplus (existing path, least used space) | Of all the upstreams on which the relative path exists choose the one with the least used space. | 85 | eplno (existing path, least number of objects) | Of all the upstreams on which the relative path exists choose the one with the least number of objects. | 86 | epmfs (existing path, most free space) | Of all the upstreams on which the relative path exists choose the one with the most free space. | 87 | eprand (existing path, random) | Calls **epall** and then randomizes. Returns only one upstream. | 88 | ff (first found) | Search category: same as **epff**. Action category: same as **epff**. Create category: Act on the first one found by the time upstreams reply. | 89 | lfs (least free space) | Search category: same as **eplfs**. Action category: same as **eplfs**. Create category: Pick the upstream with the least available free space. | 90 | lus (least used space) | Search category: same as **eplus**. Action category: same as **eplus**. Create category: Pick the upstream with the least used space. | 91 | lno (least number of objects) | Search category: same as **eplno**. Action category: same as **eplno**. Create category: Pick the upstream with the least number of objects. | 92 | mfs (most free space) | Search category: same as **epmfs**. Action category: same as **epmfs**. Create category: Pick the upstream with the most available free space. | 93 | newest | Pick the file / directory with the largest mtime. | 94 | rand (random) | Calls **all** and then randomizes. Returns only one upstream. | 95 96 ### Setup 97 98 Here is an example of how to make a union called `remote` for local folders. 99 First run: 100 101 rclone config 102 103 This will guide you through an interactive setup process: 104 105 ``` 106 No remotes found - make a new one 107 n) New remote 108 s) Set configuration password 109 q) Quit config 110 n/s/q> n 111 name> remote 112 Type of storage to configure. 113 Choose a number from below, or type in your own value 114 [snip] 115 XX / Union merges the contents of several remotes 116 \ "union" 117 [snip] 118 Storage> union 119 List of space separated upstreams. 120 Can be 'upstreama:test/dir upstreamb:', '\"upstreama:test/space:ro dir\" upstreamb:', etc. 121 Enter a string value. Press Enter for the default (""). 122 upstreams> 123 Policy to choose upstream on ACTION class. 124 Enter a string value. Press Enter for the default ("epall"). 125 action_policy> 126 Policy to choose upstream on CREATE class. 127 Enter a string value. Press Enter for the default ("epmfs"). 128 create_policy> 129 Policy to choose upstream on SEARCH class. 130 Enter a string value. Press Enter for the default ("ff"). 131 search_policy> 132 Cache time of usage and free space (in seconds). This option is only useful when a path preserving policy is used. 133 Enter a signed integer. Press Enter for the default ("120"). 134 cache_time> 135 Remote config 136 -------------------- 137 [remote] 138 type = union 139 upstreams = C:\dir1 C:\dir2 C:\dir3 140 -------------------- 141 y) Yes this is OK 142 e) Edit this remote 143 d) Delete this remote 144 y/e/d> y 145 Current remotes: 146 147 Name Type 148 ==== ==== 149 remote union 150 151 e) Edit existing remote 152 n) New remote 153 d) Delete remote 154 r) Rename remote 155 c) Copy remote 156 s) Set configuration password 157 q) Quit config 158 e/n/d/r/c/s/q> q 159 ``` 160 161 Once configured you can then use `rclone` like this, 162 163 List directories in top level in `C:\dir1`, `C:\dir2` and `C:\dir3` 164 165 rclone lsd remote: 166 167 List all the files in `C:\dir1`, `C:\dir2` and `C:\dir3` 168 169 rclone ls remote: 170 171 Copy another local directory to the union directory called source, which will be placed into `C:\dir3` 172 173 rclone copy C:\source remote:source 174 175 {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/union/union.go then run make backenddocs" >}} 176 ### Standard Options 177 178 Here are the standard options specific to union (Union merges the contents of several upstream fs). 179 180 #### --union-upstreams 181 182 List of space separated upstreams. 183 Can be 'upstreama:test/dir upstreamb:', '"upstreama:test/space:ro dir" upstreamb:', etc. 184 185 186 - Config: upstreams 187 - Env Var: RCLONE_UNION_UPSTREAMS 188 - Type: string 189 - Default: "" 190 191 #### --union-action-policy 192 193 Policy to choose upstream on ACTION category. 194 195 - Config: action_policy 196 - Env Var: RCLONE_UNION_ACTION_POLICY 197 - Type: string 198 - Default: "epall" 199 200 #### --union-create-policy 201 202 Policy to choose upstream on CREATE category. 203 204 - Config: create_policy 205 - Env Var: RCLONE_UNION_CREATE_POLICY 206 - Type: string 207 - Default: "epmfs" 208 209 #### --union-search-policy 210 211 Policy to choose upstream on SEARCH category. 212 213 - Config: search_policy 214 - Env Var: RCLONE_UNION_SEARCH_POLICY 215 - Type: string 216 - Default: "ff" 217 218 #### --union-cache-time 219 220 Cache time of usage and free space (in seconds). This option is only useful when a path preserving policy is used. 221 222 - Config: cache_time 223 - Env Var: RCLONE_UNION_CACHE_TIME 224 - Type: int 225 - Default: 120 226 227 {{< rem autogenerated options stop >}}