2017-09-30 20:01:19 +00:00
|
|
|
..
|
|
|
|
Normally, there are no heading levels assigned to certain characters as the structure is
|
|
|
|
determined from the succession of headings. However, this convention is used in Python’s
|
|
|
|
Style Guide for documenting which you may follow:
|
|
|
|
|
|
|
|
# with overline, for parts
|
|
|
|
* for chapters
|
|
|
|
= for sections
|
|
|
|
- for subsections
|
|
|
|
^ for subsubsections
|
|
|
|
" for paragraphs
|
|
|
|
|
|
|
|
#####################
|
|
|
|
Restoring from backup
|
|
|
|
#####################
|
|
|
|
|
|
|
|
Restoring from a snapshot
|
|
|
|
=========================
|
|
|
|
|
|
|
|
Restoring a snapshot is as easy as it sounds, just use the following
|
|
|
|
command to restore the contents of the latest snapshot to
|
|
|
|
``/tmp/restore-work``:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2018-04-28 14:19:16 +00:00
|
|
|
$ restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work
|
2017-09-30 20:01:19 +00:00
|
|
|
enter password for repository:
|
|
|
|
restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work
|
|
|
|
|
|
|
|
Use the word ``latest`` to restore the last backup. You can also combine
|
|
|
|
``latest`` with the ``--host`` and ``--path`` filters to choose the last
|
|
|
|
backup for a specific host, path or both.
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2018-04-28 14:19:16 +00:00
|
|
|
$ restic -r /srv/restic-repo restore latest --target /tmp/restore-art --path "/home/art" --host luigi
|
2017-09-30 20:01:19 +00:00
|
|
|
enter password for repository:
|
|
|
|
restoring <Snapshot of [/home/art] at 2015-05-08 21:45:17.884408621 +0200 CEST> to /tmp/restore-art
|
|
|
|
|
|
|
|
Use ``--exclude`` and ``--include`` to restrict the restore to a subset of
|
|
|
|
files in the snapshot. For example, to restore a single file:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2018-04-28 14:19:16 +00:00
|
|
|
$ restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work --include /work/foo
|
2017-09-30 20:01:19 +00:00
|
|
|
enter password for repository:
|
|
|
|
restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work
|
|
|
|
|
|
|
|
This will restore the file ``foo`` to ``/tmp/restore-work/work/foo``.
|
|
|
|
|
2023-07-16 14:45:54 +00:00
|
|
|
To only restore a specific subfolder, you can use the ``<snapshot>:<subfolder>``
|
2023-07-16 19:43:56 +00:00
|
|
|
syntax, where ``snapshot`` is the ID of a snapshot (or the string ``latest``)
|
|
|
|
and ``subfolder`` is a path within the snapshot.
|
2023-07-16 14:45:54 +00:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ restic -r /srv/restic-repo restore 79766175:/work --target /tmp/restore-work --include /foo
|
|
|
|
enter password for repository:
|
|
|
|
restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work
|
|
|
|
|
|
|
|
This will restore the file ``foo`` to ``/tmp/restore-work/foo``.
|
|
|
|
|
2018-06-17 18:49:11 +00:00
|
|
|
You can use the command ``restic ls latest`` or ``restic find foo`` to find the
|
2018-06-18 20:19:01 +00:00
|
|
|
path to the file within the snapshot. This path you can then pass to
|
2019-10-13 19:16:36 +00:00
|
|
|
``--include`` in verbatim to only restore the single file or directory.
|
2018-06-17 18:49:11 +00:00
|
|
|
|
2020-05-16 06:05:26 +00:00
|
|
|
There are case insensitive variants of ``--exclude`` and ``--include`` called
|
2018-10-18 19:39:41 +00:00
|
|
|
``--iexclude`` and ``--iinclude``. These options will behave the same way but
|
|
|
|
ignore the casing of paths.
|
|
|
|
|
2024-06-01 14:54:53 +00:00
|
|
|
There are also ``--include-file``, ``--exclude-file``, ``--iinclude-file`` and
|
|
|
|
``--iexclude-file`` flags that read the include and exclude patterns from a file.
|
|
|
|
|
2020-08-05 18:16:37 +00:00
|
|
|
Restoring symbolic links on windows is only possible when the user has
|
|
|
|
``SeCreateSymbolicLinkPrivilege`` privilege or is running as admin. This is a
|
|
|
|
restriction of windows not restic.
|
|
|
|
|
2024-04-29 22:21:38 +00:00
|
|
|
Restoring full security descriptors on Windows is only possible when the user has
|
2024-02-24 20:28:18 +00:00
|
|
|
``SeRestorePrivilege``, ``SeSecurityPrivilege`` and ``SeTakeOwnershipPrivilege``
|
2024-04-29 22:21:38 +00:00
|
|
|
privilege or is running as admin. This is a restriction of Windows not restic.
|
2024-02-24 20:28:18 +00:00
|
|
|
If either of these conditions are not met, only the DACL will be restored.
|
|
|
|
|
2023-01-10 22:09:19 +00:00
|
|
|
By default, restic does not restore files as sparse. Use ``restore --sparse`` to
|
|
|
|
enable the creation of sparse files if supported by the filesystem. Then restic
|
|
|
|
will restore long runs of zero bytes as holes in the corresponding files.
|
|
|
|
Reading from a hole returns the original zero bytes, but it does not consume
|
|
|
|
disk space. Note that the exact location of the holes can differ from those in
|
|
|
|
the original file, as their location is determined while restoring and is not
|
|
|
|
stored explicitly.
|
|
|
|
|
2024-05-31 14:11:18 +00:00
|
|
|
Restoring in-place
|
|
|
|
------------------
|
|
|
|
|
|
|
|
By default, the ``restore`` command overwrites already existing files in the target
|
|
|
|
directory. This behavior can be configured via the ``--overwrite`` option. The
|
|
|
|
default is ``--overwrite always``. To only overwrite existing files if the file in
|
|
|
|
the snapshot is newer, use ``--overwrite if-newer``. To never overwrite existing files,
|
|
|
|
use ``--overwrite never``.
|
|
|
|
|
2017-09-30 20:01:19 +00:00
|
|
|
Restore using mount
|
|
|
|
===================
|
|
|
|
|
|
|
|
Browsing your backup as a regular file system is also very easy. First,
|
|
|
|
create a mount point such as ``/mnt/restic`` and then use the following
|
|
|
|
command to serve the repository with FUSE:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ mkdir /mnt/restic
|
2018-04-28 14:19:16 +00:00
|
|
|
$ restic -r /srv/restic-repo mount /mnt/restic
|
2017-09-30 20:01:19 +00:00
|
|
|
enter password for repository:
|
2018-04-28 14:19:16 +00:00
|
|
|
Now serving /srv/restic-repo at /mnt/restic
|
2021-11-01 19:59:20 +00:00
|
|
|
Use another terminal or tool to browse the contents of this folder.
|
|
|
|
When finished, quit with Ctrl-c here or umount the mountpoint.
|
2017-09-30 20:01:19 +00:00
|
|
|
|
2020-06-19 11:07:41 +00:00
|
|
|
Mounting repositories via FUSE is only possible on Linux, macOS and FreeBSD.
|
|
|
|
On Linux, the ``fuse`` kernel module needs to be loaded and the ``fusermount``
|
2024-05-26 12:24:15 +00:00
|
|
|
command needs to be in the ``PATH``. On macOS, you need `FUSE-T
|
|
|
|
<https://www.fuse-t.org/>`__ or `FUSE for macOS <https://osxfuse.github.io/>`__.
|
|
|
|
On FreeBSD, you may need to install FUSE and load the kernel module (``kldload fuse``).
|
2017-09-30 20:01:19 +00:00
|
|
|
|
|
|
|
Restic supports storage and preservation of hard links. However, since
|
|
|
|
hard links exist in the scope of a filesystem by definition, restoring
|
|
|
|
hard links from a fuse mount should be done by a program that preserves
|
|
|
|
hard links. A program that does so is ``rsync``, used with the option
|
2023-10-26 06:22:44 +00:00
|
|
|
``--hard-links``.
|
2017-09-30 20:01:19 +00:00
|
|
|
|
2023-05-31 20:42:20 +00:00
|
|
|
.. note:: ``restic mount`` is mostly useful if you want to restore just a few
|
|
|
|
files out of a snapshot, or to check which files are contained in a snapshot.
|
|
|
|
To restore many files or a whole snapshot, ``restic restore`` is the best
|
|
|
|
alternative, often it is *significantly* faster.
|
|
|
|
|
2017-10-16 18:24:47 +00:00
|
|
|
Printing files to stdout
|
|
|
|
========================
|
|
|
|
|
|
|
|
Sometimes it's helpful to print files to stdout so that other programs can read
|
|
|
|
the data directly. This can be achieved by using the `dump` command, like this:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2018-04-28 14:19:16 +00:00
|
|
|
$ restic -r /srv/restic-repo dump latest production.sql | mysql
|
2018-07-14 18:45:52 +00:00
|
|
|
|
|
|
|
If you have saved multiple different things into the same repo, the ``latest``
|
|
|
|
snapshot may not be the right one. For example, consider the following
|
2022-07-12 18:48:01 +00:00
|
|
|
snapshots in a repository:
|
2018-07-14 18:45:52 +00:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ restic -r /srv/restic-repo snapshots
|
|
|
|
ID Date Host Tags Directory
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
562bfc5e 2018-07-14 20:18:01 mopped /home/user/file1
|
|
|
|
bbacb625 2018-07-14 20:18:07 mopped /home/other/work
|
|
|
|
e922c858 2018-07-14 20:18:10 mopped /home/other/work
|
|
|
|
098db9d5 2018-07-14 20:18:13 mopped /production.sql
|
|
|
|
b62f46ec 2018-07-14 20:18:16 mopped /home/user/file1
|
|
|
|
1541acae 2018-07-14 20:18:18 mopped /home/other/work
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Here, restic would resolve ``latest`` to the snapshot ``1541acae``, which does
|
|
|
|
not contain the file we'd like to print at all (``production.sql``). In this
|
|
|
|
case, you can pass restic the snapshot ID of the snapshot you like to restore:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ restic -r /srv/restic-repo dump 098db9d5 production.sql | mysql
|
|
|
|
|
|
|
|
Or you can pass restic a path that should be used for selecting the latest
|
|
|
|
snapshot. The path must match the patch printed in the "Directory" column,
|
|
|
|
e.g.:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ restic -r /srv/restic-repo dump --path /production.sql latest production.sql | mysql
|
2018-12-20 15:39:48 +00:00
|
|
|
|
|
|
|
It is also possible to ``dump`` the contents of a whole folder structure to
|
|
|
|
stdout. To retain the information about the files and folders Restic will
|
2020-12-18 22:16:15 +00:00
|
|
|
output the contents in the tar (default) or zip format:
|
2018-12-20 15:39:48 +00:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2019-05-28 16:20:52 +00:00
|
|
|
$ restic -r /srv/restic-repo dump latest /home/other/work > restore.tar
|
2023-07-16 14:45:54 +00:00
|
|
|
|
2020-11-10 01:56:21 +00:00
|
|
|
.. code-block:: console
|
2018-12-20 15:39:48 +00:00
|
|
|
|
2020-11-10 01:56:21 +00:00
|
|
|
$ restic -r /srv/restic-repo dump -a zip latest /home/other/work > restore.zip
|
2018-12-20 15:39:48 +00:00
|
|
|
|
2023-07-16 14:45:54 +00:00
|
|
|
The folder content is then contained at ``/home/other/work`` within the archive.
|
|
|
|
To include the folder content at the root of the archive, you can use the ``<snapshot>:<subfolder>`` syntax:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ restic -r /srv/restic-repo dump latest:/home/other/work / > restore.tar
|
2024-02-04 08:45:14 +00:00
|
|
|
|
|
|
|
It is also possible to ``dump`` the contents of a selected snapshot and folder
|
2024-02-10 17:38:36 +00:00
|
|
|
structure to a file using the ``--target`` flag.
|
2024-02-04 08:45:14 +00:00
|
|
|
|
|
|
|
.. code-block:: console
|
2024-05-26 12:32:09 +00:00
|
|
|
|
|
|
|
$ restic -r /srv/restic-repo dump latest / --target /home/linux.user/output.tar -a tar
|