From 569f111cb176459931fd5b83dd1c34c9dba1f8d0 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 29 Jun 2024 22:21:27 +0200 Subject: [PATCH] restore: document --delete option --- doc/050_restore.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/050_restore.rst b/doc/050_restore.rst index 497488241..5f351ae1d 100644 --- a/doc/050_restore.rst +++ b/doc/050_restore.rst @@ -111,6 +111,27 @@ values are supported: newer modification time (mtime). * ``--overwrite never``: never overwrite existing files. +Delete files not in snapshot +---------------------------- + +When restoring into a directory that already contains files, it can be useful to remove all +files that do not exist in the snapshot. For this, pass the ``--delete`` option to the ``restore`` +command. The command will then **delete all files** from the target directory that do not +exist in the snapshot. + +The ``--delete`` option also allows overwriting a non-empty directory if the snapshot contains a +file with the same name. + +.. warning:: + + Always use the ``--dry-run -vv`` option to verify what would be deleted before running the actual + command. + +When specifying ``--include`` or ``--exclude`` options, only files or directories matched by those +options will be deleted. For example, the command +``restic -r /srv/restic-repo restore 79766175:/work --target /tmp/restore-work --include /foo --delete`` +would only delete files within ``/tmp/restore-work/foo``. + Dry run -------