github.com/advanderveer/restic@v0.8.1-0.20171209104529-42a8c19aaea6/doc/manual_rest.rst (about)

     1  Manual
     2  ======
     3  
     4  Usage help
     5  ----------
     6  
     7  Usage help is available:
     8  
     9  .. code-block:: console
    10  
    11      $ ./restic --help
    12      restic is a backup program which allows saving multiple revisions of files and
    13      directories in an encrypted repository stored on different backends.
    14  
    15      Usage:
    16        restic [command]
    17  
    18      Available Commands:
    19        backup        Create a new backup of files and/or directories
    20        cat           Print internal objects to stdout
    21        check         Check the repository for errors
    22        dump          Print a backed-up file to stdout
    23        find          Find a file or directory
    24        forget        Remove snapshots from the repository
    25        generate      Generate manual pages and auto-completion files (bash, zsh)
    26        help          Help about any command
    27        init          Initialize a new repository
    28        key           Manage keys (passwords)
    29        list          List objects in the repository
    30        ls            List files in a snapshot
    31        migrate       Apply migrations
    32        mount         Mount the repository
    33        prune         Remove unneeded data from the repository
    34        rebuild-index Build a new index file
    35        restore       Extract the data from a snapshot
    36        snapshots     List all snapshots
    37        tag           Modify tags on snapshots
    38        unlock        Remove locks other processes created
    39        version       Print version information
    40  
    41      Flags:
    42            --cacert stringSlice     path to load root certificates from (default: use system certificates)
    43            --cache-dir string       set the cache directory
    44        -h, --help                   help for restic
    45            --json                   set output mode to JSON for commands that support it
    46            --limit-download int     limits downloads to a maximum rate in KiB/s. (default: unlimited)
    47            --limit-upload int       limits uploads to a maximum rate in KiB/s. (default: unlimited)
    48            --no-cache               do not use a local cache
    49            --no-lock                do not lock the repo, this allows some operations on read-only repos
    50        -o, --option key=value       set extended option (key=value, can be specified multiple times)
    51        -p, --password-file string   read the repository password from a file (default: $RESTIC_PASSWORD_FILE)
    52        -q, --quiet                  do not output comprehensive progress report
    53        -r, --repo string            repository to backup to or restore from (default: $RESTIC_REPOSITORY)
    54  
    55      Use "restic [command] --help" for more information about a command.
    56  
    57  
    58  Similar to programs such as ``git``, restic has a number of
    59  sub-commands. You can see these commands in the listing above. Each
    60  sub-command may have own command-line options, and there is a help
    61  option for each command which lists them, e.g. for the ``backup``
    62  command:
    63  
    64  .. code-block:: console
    65  
    66      $ ./restic backup --help
    67      The "backup" command creates a new snapshot and saves the files and directories
    68      given as the arguments.
    69  
    70      Usage:
    71        restic backup [flags] FILE/DIR [FILE/DIR] ...
    72  
    73      Flags:
    74        -e, --exclude pattern                  exclude a pattern (can be specified multiple times)
    75            --exclude-caches                   excludes cache directories that are marked with a CACHEDIR.TAG file
    76            --exclude-file file                read exclude patterns from a file (can be specified multiple times)
    77            --exclude-if-present stringArray   takes filename[:header], exclude contents of directories containing filename (except filename itself) if header of that file is as provided (can be specified multiple times)
    78            --files-from string                read the files to backup from file (can be combined with file args)
    79        -f, --force                            force re-reading the target files/directories (overrides the "parent" flag)
    80        -h, --help                             help for backup
    81            --hostname hostname                set the hostname for the snapshot manually. To prevent an expensive rescan use the "parent" flag
    82        -x, --one-file-system                  exclude other file systems
    83            --parent string                    use this parent snapshot (default: last snapshot in the repo that has the same target files/directories)
    84            --stdin                            read backup from stdin
    85            --stdin-filename string            file name to use when reading from stdin (default "stdin")
    86            --tag tag                          add a tag for the new snapshot (can be specified multiple times)
    87            --time string                      time of the backup (ex. '2012-11-01 22:08:41') (default: now)
    88  
    89      Global Flags:
    90            --cacert stringSlice     path to load root certificates from (default: use system certificates)
    91            --cache-dir string       set the cache directory
    92            --json                   set output mode to JSON for commands that support it
    93            --limit-download int     limits downloads to a maximum rate in KiB/s. (default: unlimited)
    94            --limit-upload int       limits uploads to a maximum rate in KiB/s. (default: unlimited)
    95            --no-cache               do not use a local cache
    96            --no-lock                do not lock the repo, this allows some operations on read-only repos
    97        -o, --option key=value       set extended option (key=value, can be specified multiple times)
    98        -p, --password-file string   read the repository password from a file (default: $RESTIC_PASSWORD_FILE)
    99        -q, --quiet                  do not output comprehensive progress report
   100        -r, --repo string            repository to backup to or restore from (default: $RESTIC_REPOSITORY)
   101  
   102  Subcommand that support showing progress information such as ``backup``,
   103  ``check`` and ``prune`` will do so unless the quiet flag ``-q`` or
   104  ``--quiet`` is set. When running from a non-interactive console progress
   105  reporting will be limited to once every 10 seconds to not fill your
   106  logs.
   107  
   108  Additionally on Unix systems if ``restic`` receives a SIGUSR1 signal the
   109  current progress will written to the standard output so you can check up
   110  on the status at will.
   111  
   112  Manage tags
   113  -----------
   114  
   115  Managing tags on snapshots is done with the ``tag`` command. The
   116  existing set of tags can be replaced completely, tags can be added to
   117  removed. The result is directly visible in the ``snapshots`` command.
   118  
   119  Let's say we want to tag snapshot ``590c8fc8`` with the tags ``NL`` and
   120  ``CH`` and remove all other tags that may be present, the following
   121  command does that:
   122  
   123  .. code-block:: console
   124  
   125      $ restic -r /tmp/backup tag --set NL --set CH 590c8fc8
   126      create exclusive lock for repository
   127      modified tags on 1 snapshots
   128  
   129  Note the snapshot ID has changed, so between each change we need to look
   130  up the new ID of the snapshot. But there is an even better way, the
   131  ``tag`` command accepts ``--tag`` for a filter, so we can filter
   132  snapshots based on the tag we just added.
   133  
   134  So we can add and remove tags incrementally like this:
   135  
   136  .. code-block:: console
   137  
   138      $ restic -r /tmp/backup tag --tag NL --remove CH
   139      create exclusive lock for repository
   140      modified tags on 1 snapshots
   141  
   142      $ restic -r /tmp/backup tag --tag NL --add UK
   143      create exclusive lock for repository
   144      modified tags on 1 snapshots
   145  
   146      $ restic -r /tmp/backup tag --tag NL --remove NL
   147      create exclusive lock for repository
   148      modified tags on 1 snapshots
   149  
   150      $ restic -r /tmp/backup tag --tag NL --add SOMETHING
   151      no snapshots were modified
   152  
   153  Under the hood
   154  --------------
   155  
   156  Browse repository objects
   157  ~~~~~~~~~~~~~~~~~~~~~~~~~
   158  
   159  Internally, a repository stores data of several different types
   160  described in the `design
   161  documentation <https://github.com/restic/restic/blob/master/doc/Design.rst>`__.
   162  You can ``list`` objects such as blobs, packs, index, snapshots, keys or
   163  locks with the following command:
   164  
   165  .. code-block:: console
   166  
   167      $ restic -r /tmp/backup list snapshots
   168      d369ccc7d126594950bf74f0a348d5d98d9e99f3215082eb69bf02dc9b3e464c
   169  
   170  The ``find`` command searches for a given
   171  `pattern <http://golang.org/pkg/path/filepath/#Match>`__ in the
   172  repository.
   173  
   174  .. code-block:: console
   175  
   176      $ restic -r backup find test.txt
   177      debug log file restic.log
   178      debug enabled
   179      enter password for repository:
   180      found 1 matching entries in snapshot 196bc5760c909a7681647949e80e5448e276521489558525680acf1bd428af36
   181        -rw-r--r--   501    20      5 2015-08-26 14:09:57 +0200 CEST path/to/test.txt
   182  
   183  The ``cat`` command allows you to display the JSON representation of the
   184  objects or its raw content.
   185  
   186  .. code-block:: console
   187  
   188      $ restic -r /tmp/backup cat snapshot d369ccc7d126594950bf74f0a348d5d98d9e99f3215082eb69bf02dc9b3e464c
   189      enter password for repository:
   190      {
   191        "time": "2015-08-12T12:52:44.091448856+02:00",
   192        "tree": "05cec17e8d3349f402576d02576a2971fc0d9f9776ce2f441c7010849c4ff5af",
   193        "paths": [
   194          "/home/user/work"
   195        ],
   196        "hostname": "kasimir",
   197        "username": "username",
   198        "uid": 501,
   199        "gid": 20
   200      }
   201  
   202  Metadata handling
   203  ~~~~~~~~~~~~~~~~~
   204  
   205  Restic saves and restores most default attributes, including extended attributes like ACLs.
   206  Sparse files are not handled in a special way yet, and aren't restored.
   207  
   208  The following metadata is handled by restic:
   209  
   210  - Name
   211  - Type
   212  - Mode
   213  - ModTime
   214  - AccessTime
   215  - ChangeTime
   216  - UID
   217  - GID
   218  - User
   219  - Group
   220  - Inode
   221  - Size
   222  - Links
   223  - LinkTarget
   224  - Device
   225  - Content
   226  - Subtree
   227  - ExtendedAttributes
   228  
   229  Scripting
   230  ---------
   231  
   232  Restic supports the output of some commands in JSON format, the JSON
   233  data can then be processed by other programs (e.g.
   234  `jq <https://stedolan.github.io/jq/>`__). The following example
   235  lists all snapshots as JSON and uses ``jq`` to pretty-print the result:
   236  
   237  .. code-block:: console
   238  
   239      $ restic -r /tmp/backup snapshots --json | jq .
   240      [
   241        {
   242          "time": "2017-03-11T09:57:43.26630619+01:00",
   243          "tree": "bf25241679533df554fc0fd0ae6dbb9dcf1859a13f2bc9dd4543c354eff6c464",
   244          "paths": [
   245            "/home/work/doc"
   246          ],
   247          "hostname": "kasimir",
   248          "username": "fd0",
   249          "uid": 1000,
   250          "gid": 100,
   251          "id": "bbeed6d28159aa384d1ccc6fa0b540644b1b9599b162d2972acda86b1b80f89e"
   252        },
   253        {
   254          "time": "2017-03-11T09:58:57.541446938+01:00",
   255          "tree": "7f8c95d3420baaac28dc51609796ae0e0ecfb4862b609a9f38ffaf7ae2d758da",
   256          "paths": [
   257            "/home/user/shared"
   258          ],
   259          "hostname": "kasimir",
   260          "username": "fd0",
   261          "uid": 1000,
   262          "gid": 100,
   263          "id": "b157d91c16f0ba56801ece3a708dfc53791fe2a97e827090d6ed9a69a6ebdca0"
   264        }
   265      ]
   266  
   267  Temporary files
   268  ---------------
   269  
   270  During some operations (e.g. ``backup`` and ``prune``) restic uses
   271  temporary files to store data. These files will, by default, be saved to
   272  the system's temporary directory, on Linux this is usually located in
   273  ``/tmp/``. The environment variable ``TMPDIR`` can be used to specify a
   274  different directory, e.g. to use the directory ``/var/tmp/restic-tmp``
   275  instead of the default, set the environment variable like this:
   276  
   277  .. code-block:: console
   278  
   279      $ export TMPDIR=/var/tmp/restic-tmp
   280      $ restic -r /tmp/backup backup ~/work
   281  
   282  
   283  
   284  Caching
   285  -------
   286  
   287  Restic keeps a cache with some files from the repository on the local machine.
   288  This allows faster operations, since meta data does not need to be loaded from
   289  a remote repository. The cache is automatically created, usually in an
   290  OS-specific cache folder:
   291  
   292   * Linux/other: ``~/.cache/restic`` (or ``$XDG_CACHE_HOME/restic``)
   293   * macOS: ``~/Library/Caches/restic``
   294   * Windows: ``%LOCALAPPDATA%/restic``
   295  
   296  The command line parameter ``--cache-dir`` can each be used to override the
   297  default cache location. The parameter ``--no-cache`` disables the cache
   298  entirely. In this case, all data is loaded from the repo.
   299  
   300  The cache is ephemeral: When a file cannot be read from the cache, it is loaded
   301  from the repository.
   302  
   303  Within the cache directory, there's a sub directory for each repository the
   304  cache was used with. Restic updates the timestamps of a repo directory each
   305  time it is used, so by looking at the timestamps of the sub directories of the
   306  cache directory it can decide which sub directories are old and probably not
   307  needed any more. You can either remove these directories manually, or run a
   308  restic command with the ``--cleanup-cache`` flag.