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

     1  ---
     2  title: "B2"
     3  description: "Backblaze B2"
     4  ---
     5  
     6  {{< icon "fa fa-fire" >}} Backblaze B2
     7  ----------------------------------------
     8  
     9  B2 is [Backblaze's cloud storage system](https://www.backblaze.com/b2/).
    10  
    11  Paths are specified as `remote:bucket` (or `remote:` for the `lsd`
    12  command.)  You may put subdirectories in too, eg `remote:bucket/path/to/dir`.
    13  
    14  Here is an example of making a b2 configuration.  First run
    15  
    16      rclone config
    17  
    18  This will guide you through an interactive setup process.  To authenticate
    19  you will either need your Account ID (a short hex number) and Master
    20  Application Key (a long hex number) OR an Application Key, which is the
    21  recommended method. See below for further details on generating and using
    22  an Application Key.
    23  
    24  ```
    25  No remotes found - make a new one
    26  n) New remote
    27  q) Quit config
    28  n/q> n
    29  name> remote
    30  Type of storage to configure.
    31  Choose a number from below, or type in your own value
    32  [snip]
    33  XX / Backblaze B2
    34     \ "b2"
    35  [snip]
    36  Storage> b2
    37  Account ID or Application Key ID
    38  account> 123456789abc
    39  Application Key
    40  key> 0123456789abcdef0123456789abcdef0123456789
    41  Endpoint for the service - leave blank normally.
    42  endpoint>
    43  Remote config
    44  --------------------
    45  [remote]
    46  account = 123456789abc
    47  key = 0123456789abcdef0123456789abcdef0123456789
    48  endpoint =
    49  --------------------
    50  y) Yes this is OK
    51  e) Edit this remote
    52  d) Delete this remote
    53  y/e/d> y
    54  ```
    55  
    56  This remote is called `remote` and can now be used like this
    57  
    58  See all buckets
    59  
    60      rclone lsd remote:
    61  
    62  Create a new bucket
    63  
    64      rclone mkdir remote:bucket
    65  
    66  List the contents of a bucket
    67  
    68      rclone ls remote:bucket
    69  
    70  Sync `/home/local/directory` to the remote bucket, deleting any
    71  excess files in the bucket.
    72  
    73      rclone sync /home/local/directory remote:bucket
    74  
    75  ### Application Keys ###
    76  
    77  B2 supports multiple [Application Keys for different access permission
    78  to B2 Buckets](https://www.backblaze.com/b2/docs/application_keys.html).
    79  
    80  You can use these with rclone too; you will need to use rclone version 1.43
    81  or later.
    82  
    83  Follow Backblaze's docs to create an Application Key with the required
    84  permission and add the `applicationKeyId` as the `account` and the
    85  `Application Key` itself as the `key`.
    86  
    87  Note that you must put the _applicationKeyId_ as the `account` – you
    88  can't use the master Account ID.  If you try then B2 will return 401
    89  errors.
    90  
    91  ### --fast-list ###
    92  
    93  This remote supports `--fast-list` which allows you to use fewer
    94  transactions in exchange for more memory. See the [rclone
    95  docs](/docs/#fast-list) for more details.
    96  
    97  ### Modified time ###
    98  
    99  The modified time is stored as metadata on the object as
   100  `X-Bz-Info-src_last_modified_millis` as milliseconds since 1970-01-01
   101  in the Backblaze standard.  Other tools should be able to use this as
   102  a modified time.
   103  
   104  Modified times are used in syncing and are fully supported. Note that
   105  if a modification time needs to be updated on an object then it will
   106  create a new version of the object.
   107  
   108  #### Restricted filename characters
   109  
   110  In addition to the [default restricted characters set](/overview/#restricted-characters)
   111  the following characters are also replaced:
   112  
   113  | Character | Value | Replacement |
   114  | --------- |:-----:|:-----------:|
   115  | \         | 0x5C  | \           |
   116  
   117  Invalid UTF-8 bytes will also be [replaced](/overview/#invalid-utf8),
   118  as they can't be used in JSON strings.
   119  
   120  ### SHA1 checksums ###
   121  
   122  The SHA1 checksums of the files are checked on upload and download and
   123  will be used in the syncing process.
   124  
   125  Large files (bigger than the limit in `--b2-upload-cutoff`) which are
   126  uploaded in chunks will store their SHA1 on the object as
   127  `X-Bz-Info-large_file_sha1` as recommended by Backblaze.
   128  
   129  For a large file to be uploaded with an SHA1 checksum, the source
   130  needs to support SHA1 checksums. The local disk supports SHA1
   131  checksums so large file transfers from local disk will have an SHA1.
   132  See [the overview](/overview/#features) for exactly which remotes
   133  support SHA1.
   134  
   135  Sources which don't support SHA1, in particular `crypt` will upload
   136  large files without SHA1 checksums.  This may be fixed in the future
   137  (see [#1767](https://github.com/rclone/rclone/issues/1767)).
   138  
   139  Files sizes below `--b2-upload-cutoff` will always have an SHA1
   140  regardless of the source.
   141  
   142  ### Transfers ###
   143  
   144  Backblaze recommends that you do lots of transfers simultaneously for
   145  maximum speed.  In tests from my SSD equipped laptop the optimum
   146  setting is about `--transfers 32` though higher numbers may be used
   147  for a slight speed improvement. The optimum number for you may vary
   148  depending on your hardware, how big the files are, how much you want
   149  to load your computer, etc.  The default of `--transfers 4` is
   150  definitely too low for Backblaze B2 though.
   151  
   152  Note that uploading big files (bigger than 200 MB by default) will use
   153  a 96 MB RAM buffer by default.  There can be at most `--transfers` of
   154  these in use at any moment, so this sets the upper limit on the memory
   155  used.
   156  
   157  ### Versions ###
   158  
   159  When rclone uploads a new version of a file it creates a [new version
   160  of it](https://www.backblaze.com/b2/docs/file_versions.html).
   161  Likewise when you delete a file, the old version will be marked hidden
   162  and still be available.  Conversely, you may opt in to a "hard delete"
   163  of files with the `--b2-hard-delete` flag which would permanently remove
   164  the file instead of hiding it.
   165  
   166  Old versions of files, where available, are visible using the 
   167  `--b2-versions` flag.
   168  
   169  **NB** Note that `--b2-versions` does not work with crypt at the
   170  moment [#1627](https://github.com/rclone/rclone/issues/1627). Using
   171  [--backup-dir](/docs/#backup-dir-dir) with rclone is the recommended
   172  way of working around this.
   173  
   174  If you wish to remove all the old versions then you can use the
   175  `rclone cleanup remote:bucket` command which will delete all the old
   176  versions of files, leaving the current ones intact.  You can also
   177  supply a path and only old versions under that path will be deleted,
   178  eg `rclone cleanup remote:bucket/path/to/stuff`.
   179  
   180  Note that `cleanup` will remove partially uploaded files from the bucket
   181  if they are more than a day old.
   182  
   183  When you `purge` a bucket, the current and the old versions will be
   184  deleted then the bucket will be deleted.
   185  
   186  However `delete` will cause the current versions of the files to
   187  become hidden old versions.
   188  
   189  Here is a session showing the listing and retrieval of an old
   190  version followed by a `cleanup` of the old versions.
   191  
   192  Show current version and all the versions with `--b2-versions` flag.
   193  
   194  ```
   195  $ rclone -q ls b2:cleanup-test
   196          9 one.txt
   197  
   198  $ rclone -q --b2-versions ls b2:cleanup-test
   199          9 one.txt
   200          8 one-v2016-07-04-141032-000.txt
   201         16 one-v2016-07-04-141003-000.txt
   202         15 one-v2016-07-02-155621-000.txt
   203  ```
   204  
   205  Retrieve an old version
   206  
   207  ```
   208  $ rclone -q --b2-versions copy b2:cleanup-test/one-v2016-07-04-141003-000.txt /tmp
   209  
   210  $ ls -l /tmp/one-v2016-07-04-141003-000.txt
   211  -rw-rw-r-- 1 ncw ncw 16 Jul  2 17:46 /tmp/one-v2016-07-04-141003-000.txt
   212  ```
   213  
   214  Clean up all the old versions and show that they've gone.
   215  
   216  ```
   217  $ rclone -q cleanup b2:cleanup-test
   218  
   219  $ rclone -q ls b2:cleanup-test
   220          9 one.txt
   221  
   222  $ rclone -q --b2-versions ls b2:cleanup-test
   223          9 one.txt
   224  ```
   225  
   226  ### Data usage ###
   227  
   228  It is useful to know how many requests are sent to the server in different scenarios.
   229  
   230  All copy commands send the following 4 requests:
   231  
   232  ```
   233  /b2api/v1/b2_authorize_account
   234  /b2api/v1/b2_create_bucket
   235  /b2api/v1/b2_list_buckets
   236  /b2api/v1/b2_list_file_names
   237  ```
   238  
   239  The `b2_list_file_names` request will be sent once for every 1k files
   240  in the remote path, providing the checksum and modification time of
   241  the listed files. As of version 1.33 issue
   242  [#818](https://github.com/rclone/rclone/issues/818) causes extra requests
   243  to be sent when using B2 with Crypt. When a copy operation does not
   244  require any files to be uploaded, no more requests will be sent.
   245  
   246  Uploading files that do not require chunking, will send 2 requests per
   247  file upload:
   248  
   249  ```
   250  /b2api/v1/b2_get_upload_url
   251  /b2api/v1/b2_upload_file/
   252  ```
   253  
   254  Uploading files requiring chunking, will send 2 requests (one each to
   255  start and finish the upload) and another 2 requests for each chunk:
   256  
   257  ```
   258  /b2api/v1/b2_start_large_file
   259  /b2api/v1/b2_get_upload_part_url
   260  /b2api/v1/b2_upload_part/
   261  /b2api/v1/b2_finish_large_file
   262  ```
   263  
   264  #### Versions ####
   265  
   266  Versions can be viewed with the `--b2-versions` flag. When it is set
   267  rclone will show and act on older versions of files.  For example
   268  
   269  Listing without `--b2-versions`
   270  
   271  ```
   272  $ rclone -q ls b2:cleanup-test
   273          9 one.txt
   274  ```
   275  
   276  And with
   277  
   278  ```
   279  $ rclone -q --b2-versions ls b2:cleanup-test
   280          9 one.txt
   281          8 one-v2016-07-04-141032-000.txt
   282         16 one-v2016-07-04-141003-000.txt
   283         15 one-v2016-07-02-155621-000.txt
   284  ```
   285  
   286  Showing that the current version is unchanged but older versions can
   287  be seen.  These have the UTC date that they were uploaded to the
   288  server to the nearest millisecond appended to them.
   289  
   290  Note that when using `--b2-versions` no file write operations are
   291  permitted, so you can't upload files or delete them.
   292  
   293  ### B2 and rclone link ###
   294  
   295  Rclone supports generating file share links for private B2 buckets.
   296  They can either be for a file for example:
   297  
   298  ```
   299  ./rclone link B2:bucket/path/to/file.txt
   300  https://f002.backblazeb2.com/file/bucket/path/to/file.txt?Authorization=xxxxxxxx
   301  
   302  ```
   303  
   304  or if run on a directory you will get:
   305  
   306  ```
   307  ./rclone link B2:bucket/path
   308  https://f002.backblazeb2.com/file/bucket/path?Authorization=xxxxxxxx
   309  ```
   310  
   311  you can then use the authorization token (the part of the url from the
   312   `?Authorization=` on) on any file path under that directory. For example:
   313  
   314  ```
   315  https://f002.backblazeb2.com/file/bucket/path/to/file1?Authorization=xxxxxxxx
   316  https://f002.backblazeb2.com/file/bucket/path/file2?Authorization=xxxxxxxx
   317  https://f002.backblazeb2.com/file/bucket/path/folder/file3?Authorization=xxxxxxxx
   318  
   319  ```
   320  
   321  {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/b2/b2.go then run make backenddocs" >}}
   322  ### Standard Options
   323  
   324  Here are the standard options specific to b2 (Backblaze B2).
   325  
   326  #### --b2-account
   327  
   328  Account ID or Application Key ID
   329  
   330  - Config:      account
   331  - Env Var:     RCLONE_B2_ACCOUNT
   332  - Type:        string
   333  - Default:     ""
   334  
   335  #### --b2-key
   336  
   337  Application Key
   338  
   339  - Config:      key
   340  - Env Var:     RCLONE_B2_KEY
   341  - Type:        string
   342  - Default:     ""
   343  
   344  #### --b2-hard-delete
   345  
   346  Permanently delete files on remote removal, otherwise hide files.
   347  
   348  - Config:      hard_delete
   349  - Env Var:     RCLONE_B2_HARD_DELETE
   350  - Type:        bool
   351  - Default:     false
   352  
   353  ### Advanced Options
   354  
   355  Here are the advanced options specific to b2 (Backblaze B2).
   356  
   357  #### --b2-endpoint
   358  
   359  Endpoint for the service.
   360  Leave blank normally.
   361  
   362  - Config:      endpoint
   363  - Env Var:     RCLONE_B2_ENDPOINT
   364  - Type:        string
   365  - Default:     ""
   366  
   367  #### --b2-test-mode
   368  
   369  A flag string for X-Bz-Test-Mode header for debugging.
   370  
   371  This is for debugging purposes only. Setting it to one of the strings
   372  below will cause b2 to return specific errors:
   373  
   374    * "fail_some_uploads"
   375    * "expire_some_account_authorization_tokens"
   376    * "force_cap_exceeded"
   377  
   378  These will be set in the "X-Bz-Test-Mode" header which is documented
   379  in the [b2 integrations checklist](https://www.backblaze.com/b2/docs/integration_checklist.html).
   380  
   381  - Config:      test_mode
   382  - Env Var:     RCLONE_B2_TEST_MODE
   383  - Type:        string
   384  - Default:     ""
   385  
   386  #### --b2-versions
   387  
   388  Include old versions in directory listings.
   389  Note that when using this no file write operations are permitted,
   390  so you can't upload files or delete them.
   391  
   392  - Config:      versions
   393  - Env Var:     RCLONE_B2_VERSIONS
   394  - Type:        bool
   395  - Default:     false
   396  
   397  #### --b2-upload-cutoff
   398  
   399  Cutoff for switching to chunked upload.
   400  
   401  Files above this size will be uploaded in chunks of "--b2-chunk-size".
   402  
   403  This value should be set no larger than 4.657GiB (== 5GB).
   404  
   405  - Config:      upload_cutoff
   406  - Env Var:     RCLONE_B2_UPLOAD_CUTOFF
   407  - Type:        SizeSuffix
   408  - Default:     200M
   409  
   410  #### --b2-chunk-size
   411  
   412  Upload chunk size. Must fit in memory.
   413  
   414  When uploading large files, chunk the file into this size.  Note that
   415  these chunks are buffered in memory and there might a maximum of
   416  "--transfers" chunks in progress at once.  5,000,000 Bytes is the
   417  minimum size.
   418  
   419  - Config:      chunk_size
   420  - Env Var:     RCLONE_B2_CHUNK_SIZE
   421  - Type:        SizeSuffix
   422  - Default:     96M
   423  
   424  #### --b2-disable-checksum
   425  
   426  Disable checksums for large (> upload cutoff) files
   427  
   428  Normally rclone will calculate the SHA1 checksum of the input before
   429  uploading it so it can add it to metadata on the object. This is great
   430  for data integrity checking but can cause long delays for large files
   431  to start uploading.
   432  
   433  - Config:      disable_checksum
   434  - Env Var:     RCLONE_B2_DISABLE_CHECKSUM
   435  - Type:        bool
   436  - Default:     false
   437  
   438  #### --b2-download-url
   439  
   440  Custom endpoint for downloads.
   441  
   442  This is usually set to a Cloudflare CDN URL as Backblaze offers
   443  free egress for data downloaded through the Cloudflare network.
   444  This is probably only useful for a public bucket.
   445  Leave blank if you want to use the endpoint provided by Backblaze.
   446  
   447  - Config:      download_url
   448  - Env Var:     RCLONE_B2_DOWNLOAD_URL
   449  - Type:        string
   450  - Default:     ""
   451  
   452  #### --b2-download-auth-duration
   453  
   454  Time before the authorization token will expire in s or suffix ms|s|m|h|d.
   455  
   456  The duration before the download authorization token will expire.
   457  The minimum value is 1 second. The maximum value is one week.
   458  
   459  - Config:      download_auth_duration
   460  - Env Var:     RCLONE_B2_DOWNLOAD_AUTH_DURATION
   461  - Type:        Duration
   462  - Default:     1w
   463  
   464  #### --b2-encoding
   465  
   466  This sets the encoding for the backend.
   467  
   468  See: the [encoding section in the overview](/overview/#encoding) for more info.
   469  
   470  - Config:      encoding
   471  - Env Var:     RCLONE_B2_ENCODING
   472  - Type:        MultiEncoder
   473  - Default:     Slash,BackSlash,Del,Ctl,InvalidUtf8,Dot
   474  
   475  {{< rem autogenerated options stop >}}
   476