Manpage/btrfs-restore

From btrfs Wiki
(Difference between revisions)
Jump to: navigation, search
(Update from git, v4.5.3)
(Update from git, v4.7+)
Line 12: Line 12:
  
 
<p><b>btrfs restore</b> is used to try to salvage files from a damaged filesystem and
 
<p><b>btrfs restore</b> is used to try to salvage files from a damaged filesystem and
restore them into <em>&lt;path&gt;</em> or just list the tree roots.</p>
+
restore them into <em>&lt;path&gt;</em> or just list the subvolume tree roots. The filesystem
<p>Since current [[Manpage/btrfs-check|btrfs-check(8)]] or [[Manpage/btrfs-rescue|btrfs-rescue(8)]] only has very limited usage,
+
image is not modified.</p>
<b>btrfs restore</b> is normally a better choice.</p>
+
<p>If the filesystem is damaged and cannot be repaired by the other tools
 +
([[Manpage/btrfs-check|btrfs-check(8)]] or [[Manpage/btrfs-rescue|btrfs-rescue(8)]]), <b>btrfs restore</b> could be used to
 +
retrieve file data, as far as the metadata are readable. The checks done by
 +
restore are less strict and the process is usually able to get far enough to
 +
retrieve data from the whole filesystem. This comes at a cost that some data
 +
might be incomplete or from older versions if they&#8217;re available.</p>
 +
<p>There are several options to attempt restoration of various file metadata type.
 +
You can try a dry run first to see how well the process goes and use further
 +
options to extend the set of restored metadata.</p>
 +
<p>For images with damaged tree structures, there are several options to point the
 +
process to some spare copy.</p>
 
<blockquote><b>Note:</b>
 
<blockquote><b>Note:</b>
 
It is recommended to read the following btrfs wiki page if your data is
 
It is recommended to read the following btrfs wiki page if your data is
Line 26: Line 36:
 
<dd>
 
<dd>
 
<p>
 
<p>
get snapshots, btrfs restore skips snapshots in default.
+
get also snapshots that are skippped by default
 
</p>
 
</p>
  
Line 33: Line 43:
 
<dd>
 
<dd>
 
<p>
 
<p>
get extended attributes.
+
get extended attributes
 
</p>
 
</p>
  
Line 40: Line 50:
 
<dd>
 
<dd>
 
<p>
 
<p>
restore owner, mode and times.
+
restore owner, mode and times for files and directories
 
</p>
 
</p>
  
Line 47: Line 57:
 
<dd>
 
<dd>
 
<p>
 
<p>
restore symbolic links as well as normal files.
+
restore symbolic links as well as normal files
 
</p>
 
</p>
  
Line 54: Line 64:
 
<dd>
 
<dd>
 
<p>
 
<p>
verbose.
+
be verbose and print what is being restored
 
</p>
 
</p>
  
Line 61: Line 71:
 
<dd>
 
<dd>
 
<p>
 
<p>
ignore errors.
+
ignore errors during restoration and continue
 
</p>
 
</p>
  
Line 68: Line 78:
 
<dd>
 
<dd>
 
<p>
 
<p>
overwrite directories/files in <em>&lt;path&gt;</em>.
+
overwrite directories/files in <em>&lt;path&gt;</em>, eg. for repeated runs
 
</p>
 
</p>
  
Line 75: Line 85:
 
<dd>
 
<dd>
 
<p>
 
<p>
use <em>&lt;bytenr&gt;</em> to read root tree.
+
use <em>&lt;bytenr&gt;</em> to read the root tree
 
</p>
 
</p>
  
Line 82: Line 92:
 
<dd>
 
<dd>
 
<p>
 
<p>
only restore files that are under specified root whose root bytenr is <em>&lt;bytenr&gt;</em>.
+
only restore files that are under specified subvolume root pointed by <em>&lt;bytenr&gt;</em>
 
</p>
 
</p>
  
Line 89: Line 99:
 
<dd>
 
<dd>
 
<p>
 
<p>
use given superblock mirror identified by <em>&lt;mirror&gt;</em>, it can be 0,1,2.
+
use given superblock mirror identified by <em>&lt;mirror&gt;</em>, it can be 0,1 or 2
 
</p>
 
</p>
  
Line 96: Line 106:
 
<dd>
 
<dd>
 
<p>
 
<p>
only restore files that are under specified root whose objectid is <em>&lt;rootid&gt;</em>.
+
only restore files that are under a specified subvolume whose objectid is <em>&lt;rootid&gt;</em>
 
</p>
 
</p>
  
Line 103: Line 113:
 
<dd>
 
<dd>
 
<p>
 
<p>
find dir.
+
find directory
 
</p>
 
</p>
  
Line 110: Line 120:
 
<dd>
 
<dd>
 
<p>
 
<p>
list tree roots.
+
list subvolume tree roots, can be used as argument for <em>-r</em>
 
</p>
 
</p>
  
Line 117: Line 127:
 
<dd>
 
<dd>
 
<p>
 
<p>
dry run (only list files that would be recovered).
+
dry run (only list files that would be recovered)
 
</p>
 
</p>
  
Line 124: Line 134:
 
<dd>
 
<dd>
 
<p>
 
<p>
restore only filenames matching regex, you have to use following syntax (possibly quoted):
+
restore only filenames matching a regular expression ([http://man7.org/linux/man-pages/man7/regex.7.html regex(7)]) with a
 +
mandatory format
 
</p>
 
</p>
 
<p><tt>^/(|home(|/username(|/Desktop(|/.*))))$</tt></p>
 
<p><tt>^/(|home(|/username(|/Desktop(|/.*))))$</tt></p>
 +
<p>The format is not very comfortable and restores all files in the directories
 +
in the whole path, so this is not useful for restoring single file in a deep
 +
hierarchy.</p>
  
 
<dt>
 
<dt>
Line 132: Line 146:
 
<dd>
 
<dd>
 
<p>
 
<p>
ignore case (--path-regex only).
+
ignore case (--path-regex only)
 
</p>
 
</p>
  

Revision as of 17:44, 18 August 2016

Contents

btrfs-restore(8) manual page

Note: manual pages are located at read-the-docs site, please update your links.



NAME

btrfs-restore - try to restore files from a damaged btrfs filesystem image

SYNOPSIS

btrfs restore [options] <device> <path> | -l <device>

DESCRIPTION

btrfs restore is used to try to salvage files from a damaged filesystem and restore them into <path> or just list the subvolume tree roots. The filesystem image is not modified.

If the filesystem is damaged and cannot be repaired by the other tools (btrfs-check(8) or btrfs-rescue(8)), btrfs restore could be used to retrieve file data, as far as the metadata are readable. The checks done by restore are less strict and the process is usually able to get far enough to retrieve data from the whole filesystem. This comes at a cost that some data might be incomplete or from older versions if they’re available.

There are several options to attempt restoration of various file metadata type. You can try a dry run first to see how well the process goes and use further options to extend the set of restored metadata.

For images with damaged tree structures, there are several options to point the process to some spare copy.

Note: It is recommended to read the following btrfs wiki page if your data is not salvaged with default option:
https://btrfs.wiki.kernel.org/index.php/Restore

OPTIONS

-s|--snapshots

get also snapshots that are skippped by default

-x|--xattr

get extended attributes

-m|--metadata

restore owner, mode and times for files and directories

-S|--symlinks

restore symbolic links as well as normal files

-v|--verbose

be verbose and print what is being restored

-i|--ignore-errors

ignore errors during restoration and continue

-o|--overwrite

overwrite directories/files in <path>, eg. for repeated runs

-t <bytenr>

use <bytenr> to read the root tree

-f <bytenr>

only restore files that are under specified subvolume root pointed by <bytenr>

-u|--super <mirror>

use given superblock mirror identified by <mirror>, it can be 0,1 or 2

-r|--root <rootid>

only restore files that are under a specified subvolume whose objectid is <rootid>

-d

find directory

-l|--list-roots

list subvolume tree roots, can be used as argument for -r

-D|--dry-run

dry run (only list files that would be recovered)

--path-regex <regex>

restore only filenames matching a regular expression (regex(7)) with a mandatory format

^/(|home(|/username(|/Desktop(|/.*))))$

The format is not very comfortable and restores all files in the directories in the whole path, so this is not useful for restoring single file in a deep hierarchy.

-c

ignore case (--path-regex only)

EXIT STATUS

btrfs restore returns a zero exit status if it succeeds. Non zero is returned in case of failure.

AVAILABILITY

btrfs is part of btrfs-progs. Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for further details.

SEE ALSO

mkfs.btrfs(8), btrfs-rescue(8), btrfs-check(8)

Personal tools