github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/docs/content/commands/rclone_serve_restic.md (about)

     1  ---
     2  title: "rclone serve restic"
     3  description: "Serve the remote for restic's REST API."
     4  slug: rclone_serve_restic
     5  url: /commands/rclone_serve_restic/
     6  versionIntroduced: v1.40
     7  # autogenerated - DO NOT EDIT, instead edit the source code in cmd/serve/restic/ and as part of making a release run "make commanddocs"
     8  ---
     9  # rclone serve restic
    10  
    11  Serve the remote for restic's REST API.
    12  
    13  ## Synopsis
    14  
    15  Run a basic web server to serve a remote over restic's REST backend
    16  API over HTTP.  This allows restic to use rclone as a data storage
    17  mechanism for cloud providers that restic does not support directly.
    18  
    19  [Restic](https://restic.net/) is a command-line program for doing
    20  backups.
    21  
    22  The server will log errors.  Use -v to see access logs.
    23  
    24  `--bwlimit` will be respected for file transfers.
    25  Use `--stats` to control the stats printing.
    26  
    27  ## Setting up rclone for use by restic ###
    28  
    29  First [set up a remote for your chosen cloud provider](/docs/#configure).
    30  
    31  Once you have set up the remote, check it is working with, for example
    32  "rclone lsd remote:".  You may have called the remote something other
    33  than "remote:" - just substitute whatever you called it in the
    34  following instructions.
    35  
    36  Now start the rclone restic server
    37  
    38      rclone serve restic -v remote:backup
    39  
    40  Where you can replace "backup" in the above by whatever path in the
    41  remote you wish to use.
    42  
    43  By default this will serve on "localhost:8080" you can change this
    44  with use of the `--addr` flag.
    45  
    46  You might wish to start this server on boot.
    47  
    48  Adding `--cache-objects=false` will cause rclone to stop caching objects
    49  returned from the List call. Caching is normally desirable as it speeds
    50  up downloading objects, saves transactions and uses very little memory.
    51  
    52  ## Setting up restic to use rclone ###
    53  
    54  Now you can [follow the restic
    55  instructions](http://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html#rest-server)
    56  on setting up restic.
    57  
    58  Note that you will need restic 0.8.2 or later to interoperate with
    59  rclone.
    60  
    61  For the example above you will want to use "http://localhost:8080/" as
    62  the URL for the REST server.
    63  
    64  For example:
    65  
    66      $ export RESTIC_REPOSITORY=rest:http://localhost:8080/
    67      $ export RESTIC_PASSWORD=yourpassword
    68      $ restic init
    69      created restic backend 8b1a4b56ae at rest:http://localhost:8080/
    70  
    71      Please note that knowledge of your password is required to access
    72      the repository. Losing your password means that your data is
    73      irrecoverably lost.
    74      $ restic backup /path/to/files/to/backup
    75      scan [/path/to/files/to/backup]
    76      scanned 189 directories, 312 files in 0:00
    77      [0:00] 100.00%  38.128 MiB / 38.128 MiB  501 / 501 items  0 errors  ETA 0:00
    78      duration: 0:00
    79      snapshot 45c8fdd8 saved
    80  
    81  ### Multiple repositories ####
    82  
    83  Note that you can use the endpoint to host multiple repositories.  Do
    84  this by adding a directory name or path after the URL.  Note that
    85  these **must** end with /.  Eg
    86  
    87      $ export RESTIC_REPOSITORY=rest:http://localhost:8080/user1repo/
    88      # backup user1 stuff
    89      $ export RESTIC_REPOSITORY=rest:http://localhost:8080/user2repo/
    90      # backup user2 stuff
    91  
    92  ### Private repositories ####
    93  
    94  The`--private-repos` flag can be used to limit users to repositories starting
    95  with a path of `/<username>/`.
    96  
    97  ## Server options
    98  
    99  Use `--addr` to specify which IP address and port the server should
   100  listen on, eg `--addr 1.2.3.4:8000` or `--addr :8080` to listen to all
   101  IPs.  By default it only listens on localhost.  You can use port
   102  :0 to let the OS choose an available port.
   103  
   104  If you set `--addr` to listen on a public or LAN accessible IP address
   105  then using Authentication is advised - see the next section for info.
   106  
   107  You can use a unix socket by setting the url to `unix:///path/to/socket`
   108  or just by using an absolute path name. Note that unix sockets bypass the
   109  authentication - this is expected to be done with file system permissions.
   110  
   111  `--addr` may be repeated to listen on multiple IPs/ports/sockets.
   112  
   113  `--server-read-timeout` and `--server-write-timeout` can be used to
   114  control the timeouts on the server.  Note that this is the total time
   115  for a transfer.
   116  
   117  `--max-header-bytes` controls the maximum number of bytes the server will
   118  accept in the HTTP header.
   119  
   120  `--baseurl` controls the URL prefix that rclone serves from.  By default
   121  rclone will serve from the root.  If you used `--baseurl "/rclone"` then
   122  rclone would serve from a URL starting with "/rclone/".  This is
   123  useful if you wish to proxy rclone serve.  Rclone automatically
   124  inserts leading and trailing "/" on `--baseurl`, so `--baseurl "rclone"`,
   125  `--baseurl "/rclone"` and `--baseurl "/rclone/"` are all treated
   126  identically.
   127  
   128  ### TLS (SSL)
   129  
   130  By default this will serve over http.  If you want you can serve over
   131  https.  You will need to supply the `--cert` and `--key` flags.
   132  If you wish to do client side certificate validation then you will need to
   133  supply `--client-ca` also.
   134  
   135  `--cert` should be a either a PEM encoded certificate or a concatenation
   136  of that with the CA certificate.  `--key` should be the PEM encoded
   137  private key and `--client-ca` should be the PEM encoded client
   138  certificate authority certificate.
   139  
   140  --min-tls-version is minimum TLS version that is acceptable. Valid
   141    values are "tls1.0", "tls1.1", "tls1.2" and "tls1.3" (default
   142    "tls1.0").
   143  
   144  ### Authentication
   145  
   146  By default this will serve files without needing a login.
   147  
   148  You can either use an htpasswd file which can take lots of users, or
   149  set a single username and password with the `--user` and `--pass` flags.
   150  
   151  If no static users are configured by either of the above methods, and client
   152  certificates are required by the `--client-ca` flag passed to the server, the
   153  client certificate common name will be considered as the username.
   154  
   155  Use `--htpasswd /path/to/htpasswd` to provide an htpasswd file.  This is
   156  in standard apache format and supports MD5, SHA1 and BCrypt for basic
   157  authentication.  Bcrypt is recommended.
   158  
   159  To create an htpasswd file:
   160  
   161      touch htpasswd
   162      htpasswd -B htpasswd user
   163      htpasswd -B htpasswd anotherUser
   164  
   165  The password file can be updated while rclone is running.
   166  
   167  Use `--realm` to set the authentication realm.
   168  
   169  Use `--salt` to change the password hashing salt from the default.
   170  
   171  
   172  ```
   173  rclone serve restic remote:path [flags]
   174  ```
   175  
   176  ## Options
   177  
   178  ```
   179        --addr stringArray                IPaddress:Port or :Port to bind server to (default [127.0.0.1:8080])
   180        --allow-origin string             Origin which cross-domain request (CORS) can be executed from
   181        --append-only                     Disallow deletion of repository data
   182        --baseurl string                  Prefix for URLs - leave blank for root
   183        --cache-objects                   Cache listed objects (default true)
   184        --cert string                     TLS PEM key (concatenation of certificate and CA certificate)
   185        --client-ca string                Client certificate authority to verify clients with
   186    -h, --help                            help for restic
   187        --htpasswd string                 A htpasswd file - if not provided no authentication is done
   188        --key string                      TLS PEM Private key
   189        --max-header-bytes int            Maximum size of request header (default 4096)
   190        --min-tls-version string          Minimum TLS version that is acceptable (default "tls1.0")
   191        --pass string                     Password for authentication
   192        --private-repos                   Users can only access their private repo
   193        --realm string                    Realm for authentication
   194        --salt string                     Password hashing salt (default "dlPL2MqE")
   195        --server-read-timeout Duration    Timeout for server reading data (default 1h0m0s)
   196        --server-write-timeout Duration   Timeout for server writing data (default 1h0m0s)
   197        --stdio                           Run an HTTP2 server on stdin/stdout
   198        --user string                     User name for authentication
   199  ```
   200  
   201  
   202  See the [global flags page](/flags/) for global options not listed here.
   203  
   204  # SEE ALSO
   205  
   206  * [rclone serve](/commands/rclone_serve/)	 - Serve a remote over a protocol.
   207