github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/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  # autogenerated - DO NOT EDIT, instead edit the source code in cmd/serve/restic/ and as part of making a release run "make commanddocs"
     7  ---
     8  # rclone serve restic
     9  
    10  Serve the remote for restic's REST API.
    11  
    12  ## Synopsis
    13  
    14  rclone serve restic implements restic's REST backend API
    15  over HTTP.  This allows restic to use rclone as a data storage
    16  mechanism for cloud providers that restic does not support directly.
    17  
    18  [Restic](https://restic.net/) is a command line program for doing
    19  backups.
    20  
    21  The server will log errors.  Use -v to see access logs.
    22  
    23  --bwlimit will be respected for file transfers.  Use --stats to
    24  control the stats printing.
    25  
    26  ## Setting up rclone for use by restic ###
    27  
    28  First [set up a remote for your chosen cloud provider](/docs/#configure).
    29  
    30  Once you have set up the remote, check it is working with, for example
    31  "rclone lsd remote:".  You may have called the remote something other
    32  than "remote:" - just substitute whatever you called it in the
    33  following instructions.
    34  
    35  Now start the rclone restic server
    36  
    37      rclone serve restic -v remote:backup
    38  
    39  Where you can replace "backup" in the above by whatever path in the
    40  remote you wish to use.
    41  
    42  By default this will serve on "localhost:8080" you can change this
    43  with use of the "--addr" flag.
    44  
    45  You might wish to start this server on boot.
    46  
    47  ## Setting up restic to use rclone ###
    48  
    49  Now you can [follow the restic
    50  instructions](http://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html#rest-server)
    51  on setting up restic.
    52  
    53  Note that you will need restic 0.8.2 or later to interoperate with
    54  rclone.
    55  
    56  For the example above you will want to use "http://localhost:8080/" as
    57  the URL for the REST server.
    58  
    59  For example:
    60  
    61      $ export RESTIC_REPOSITORY=rest:http://localhost:8080/
    62      $ export RESTIC_PASSWORD=yourpassword
    63      $ restic init
    64      created restic backend 8b1a4b56ae at rest:http://localhost:8080/
    65  
    66      Please note that knowledge of your password is required to access
    67      the repository. Losing your password means that your data is
    68      irrecoverably lost.
    69      $ restic backup /path/to/files/to/backup
    70      scan [/path/to/files/to/backup]
    71      scanned 189 directories, 312 files in 0:00
    72      [0:00] 100.00%  38.128 MiB / 38.128 MiB  501 / 501 items  0 errors  ETA 0:00
    73      duration: 0:00
    74      snapshot 45c8fdd8 saved
    75  
    76  ### Multiple repositories ####
    77  
    78  Note that you can use the endpoint to host multiple repositories.  Do
    79  this by adding a directory name or path after the URL.  Note that
    80  these **must** end with /.  Eg
    81  
    82      $ export RESTIC_REPOSITORY=rest:http://localhost:8080/user1repo/
    83      # backup user1 stuff
    84      $ export RESTIC_REPOSITORY=rest:http://localhost:8080/user2repo/
    85      # backup user2 stuff
    86  
    87  ### Private repositories ####
    88  
    89  The "--private-repos" flag can be used to limit users to repositories starting
    90  with a path of `/<username>/`.
    91  
    92  ## Server options
    93  
    94  Use --addr to specify which IP address and port the server should
    95  listen on, eg --addr 1.2.3.4:8000 or --addr :8080 to listen to all
    96  IPs.  By default it only listens on localhost.  You can use port
    97  :0 to let the OS choose an available port.
    98  
    99  If you set --addr to listen on a public or LAN accessible IP address
   100  then using Authentication is advised - see the next section for info.
   101  
   102  --server-read-timeout and --server-write-timeout can be used to
   103  control the timeouts on the server.  Note that this is the total time
   104  for a transfer.
   105  
   106  --max-header-bytes controls the maximum number of bytes the server will
   107  accept in the HTTP header.
   108  
   109  --baseurl controls the URL prefix that rclone serves from.  By default
   110  rclone will serve from the root.  If you used --baseurl "/rclone" then
   111  rclone would serve from a URL starting with "/rclone/".  This is
   112  useful if you wish to proxy rclone serve.  Rclone automatically
   113  inserts leading and trailing "/" on --baseurl, so --baseurl "rclone",
   114  --baseurl "/rclone" and --baseurl "/rclone/" are all treated
   115  identically.
   116  
   117  --template allows a user to specify a custom markup template for http
   118  and webdav serve functions.  The server exports the following markup
   119  to be used within the template to server pages:
   120  
   121  | Parameter   | Description |
   122  | :---------- | :---------- |
   123  | .Name       | The full path of a file/directory. |
   124  | .Title      | Directory listing of .Name |
   125  | .Sort       | The current sort used.  This is changeable via ?sort= parameter |
   126  |             | Sort Options: namedirfist,name,size,time (default namedirfirst) |
   127  | .Order      | The current ordering used.  This is changeable via ?order= parameter |
   128  |             | Order Options: asc,desc (default asc) |
   129  | .Query      | Currently unused. |
   130  | .Breadcrumb | Allows for creating a relative navigation |
   131  |-- .Link     | The relative to the root link of the Text. |
   132  |-- .Text     | The Name of the directory. |
   133  | .Entries    | Information about a specific file/directory. |
   134  |-- .URL      | The 'url' of an entry.  |
   135  |-- .Leaf     | Currently same as 'URL' but intended to be 'just' the name. |
   136  |-- .IsDir    | Boolean for if an entry is a directory or not. |
   137  |-- .Size     | Size in Bytes of the entry. |
   138  |-- .ModTime  | The UTC timestamp of an entry. |
   139  
   140  ### Authentication
   141  
   142  By default this will serve files without needing a login.
   143  
   144  You can either use an htpasswd file which can take lots of users, or
   145  set a single username and password with the --user and --pass flags.
   146  
   147  Use --htpasswd /path/to/htpasswd to provide an htpasswd file.  This is
   148  in standard apache format and supports MD5, SHA1 and BCrypt for basic
   149  authentication.  Bcrypt is recommended.
   150  
   151  To create an htpasswd file:
   152  
   153      touch htpasswd
   154      htpasswd -B htpasswd user
   155      htpasswd -B htpasswd anotherUser
   156  
   157  The password file can be updated while rclone is running.
   158  
   159  Use --realm to set the authentication realm.
   160  
   161  ### SSL/TLS
   162  
   163  By default this will serve over http.  If you want you can serve over
   164  https.  You will need to supply the --cert and --key flags.  If you
   165  wish to do client side certificate validation then you will need to
   166  supply --client-ca also.
   167  
   168  --cert should be either a PEM encoded certificate or a concatenation
   169  of that with the CA certificate.  --key should be the PEM encoded
   170  private key and --client-ca should be the PEM encoded client
   171  certificate authority certificate.
   172  
   173  
   174  ```
   175  rclone serve restic remote:path [flags]
   176  ```
   177  
   178  ## Options
   179  
   180  ```
   181        --addr string                     IPaddress:Port or :Port to bind server to. (default "localhost:8080")
   182        --append-only                     disallow deletion of repository data
   183        --baseurl string                  Prefix for URLs - leave blank for root.
   184        --cert string                     SSL 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                 htpasswd file - if not provided no authentication is done
   188        --key string                      SSL PEM Private key
   189        --max-header-bytes int            Maximum size of request header (default 4096)
   190        --pass string                     Password for authentication.
   191        --private-repos                   users can only access their private repo
   192        --realm string                    realm for authentication (default "rclone")
   193        --server-read-timeout duration    Timeout for server reading data (default 1h0m0s)
   194        --server-write-timeout duration   Timeout for server writing data (default 1h0m0s)
   195        --stdio                           run an HTTP2 server on stdin/stdout
   196        --template string                 User Specified Template.
   197        --user string                     User name for authentication.
   198  ```
   199  
   200  See the [global flags page](/flags/) for global options not listed here.
   201  
   202  ## SEE ALSO
   203  
   204  * [rclone serve](/commands/rclone_serve/)	 - Serve a remote over a protocol.
   205