Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing "diff only" ZFS snapshot

Tags:

zfs

Is there a way to mount a virtual partition containing only the files specific to a snapshot? I know about the hidden zfs directory but it contains all files at the snapshot time. My goal is to make diff backup faster...

Thanks in advance

greg

like image 495
greg Avatar asked Dec 24 '22 08:12

greg


1 Answers

Although Andrew's suggestion of zfs send is the right way to work with differential snapshots, if you just want to see the differences and work with them in your own scripts or on other platforms without ZFS support, there also is zfs diff:

zfs diff [-FHt] snapshot snapshot|filesystem

Display the difference between a snapshot of a given filesystem
and another snapshot of that filesystem from a later time or
the current contents of the filesystem.  The first column is a
character indicating the type of change, the other columns
indicate pathname, new pathname (in case of rename), change in
link count, and optionally file type and/or change time.

The types of change are:
  -       The path has been removed
  +       The path has been created
  M       The path has been modified
  R       The path has been renamed

-F
    Display an indication of the type of file, in a manner
    similar to the -F option of ls(1).
      B       Block device
      C       Character device
      /       Directory
      >       Door
      |       Named pipe
      @       Symbolic link
      P       Event port
      =       Socket
      F       Regular file
-H
    Give more parsable tab-separated output, without header
    lines and without arrows.
-t
    Display the path's inode change time as the first column of
    output.

Note that the order of the two datasets must be chronological. You could parse the resulting list and only work with those filenames you are interested in.

Example output from the man page:

# zfs diff -F tank/test@before tank/test
M       /       /tank/test/
M       F       /tank/test/linked      (+1)
R       F       /tank/test/oldname -> /tank/test/newname
-       F       /tank/test/deleted
+       F       /tank/test/created
M       F       /tank/test/modified

Also, if you use Oracle Solaris 11.3, you also have the -r switch to recursively diff all children datasets.

like image 147
user121391 Avatar answered Apr 15 '23 08:04

user121391