git: hammer2 - Add "hammer2 recover" directive, recover/undo single file, part 1
Matthew Dillon
dillon at crater.dragonflybsd.org
Thu Sep 28 16:08:54 PDT 2023
commit ca5510ac27b528f1e30fafa6846d471e3ff6ea6a
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Thu Sep 28 15:52:33 2023 -0700
hammer2 - Add "hammer2 recover" directive, recover/undo single file, part 1
* Adds the 'hammer2 recover' directive. The initial commit only allows
a single filename to be recovered. You specify the filename, not a
path.
A future version of this directive will be capable of recovering
whole directory structures. This initial version can be used to
recover important specific files that you absolutely need to undo
or restore.
* This directive requires root access because it does a raw scan of the
hammer2 media. The media will be scanned in 2 passes, so a recovery
operation can take a while.
The operation may be executed on live media. However, if trying to
restore a deleted file you might want to temporarily disable the
hammer2 periodics until recovery is done to ensure that a bulkfree
operation is not executed during the restoral. This will improve
your chances of restoring the lost files.
Note that the scan does not currently make the distinction between
data blocks and meta-data blocks. It scans everything under the
assumption that the media might be corrupt. Thus it is possible
for user data to be misinterpreted as meta-data. However, even
though this is possible, the scan does CRC checks and further
validation so in all likelihood user data will not confuse it.
* In pass 1, the operation scans the media for stuff that looks like
directory entries. If the filename is found, the inode number is
recorded in pass 1.
In pass 2, searches the media for blockref entries for inodes matching
any inode number found in pass 1. Matching entries are restored
as "<destdir>/<filename>.<sequence_number>", %05ld so
.00001, .00002, etc.
Multiple versions of the same file with the same inode number,
multiple versions of the same file with different inode numbers,
and different files with the same filename, will all be restored.
* The recovery operation is able to validate the full content of the
inode. If any content is found to be corrupted, as much of the file
as possible will be restored but the file will be renamed
"<filename>.<seqno>.corrupted" and perms will not be restored.
Ownership and mtime will still be restored.
Summary of changes:
sbin/hammer2/Makefile | 1 +
sbin/hammer2/cmd_recover.c | 508 ++++++++++++++++++++++++++++++++++++++++++++
sbin/hammer2/hammer2.h | 1 +
sbin/hammer2/hammer2_subs.h | 1 +
sbin/hammer2/main.c | 13 ++
sbin/hammer2/ondisk.c | 21 ++
6 files changed, 545 insertions(+)
create mode 100644 sbin/hammer2/cmd_recover.c
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/ca5510ac27b528f1e30fafa6846d471e3ff6ea6a
--
DragonFly BSD source repository
More information about the Commits
mailing list