How to Create a ZFS File System Snapshot

How to Create a ZFS File System Snapshot

A good practice is to create a snapshot of important data on a regular basis. Then, back up the snapshot to a disk or tape.

Starting in the OpenSolaris 2008.11 release, an automatic snapshot service is available to manage automatic snapshots. For more information, see http://wikis.sun.com/display/OpenSolarisInfo/How+to+Manage+Automatic+ZFS+Snapshots.

Steps
  1. Start a privileged shell.

    user@opensolaris:-$ pfexec bash
    #
    

    In this example, the bash shell is selected. You can choose to use any shell with the pfexec command. If you support multiple versions of the SolarisTM OS, use the standard su – root command. The su command works on all Solaris versions.

  2. Create a file system for storing data.
    For example:
    # /usr/sbin/zfs create rpool/export/home/data
    
  3. Create a snapshot of a ZFS file system.
    For example, a snapshot called data@0805 is created. It contains all of the file system data at the time that the snapshot was taken.
    $ /usr/sbin/zfs snapshot rpool/export/home/data@0805
    
  4. Verify the file system snapshot.
    $ /usr/sbin/zfs list -t snapshot
    NAME                         USED  AVAIL  REFER  MOUNTPOINT
    rpool/export/home/data@0805      0      -  77.8M  -
    
  5. (Optional) If you accidentally delete a file, you can restore it from the file system snapshot.
    For example, file.3 is restored from the .zfs/snapshot/0805 directory.
    $ pwd
    /export/home/data
    # cp .zfs/snapshot/0805/file.3 file.3
    # ls /export/home/data
    file.1  file.2  file.3
    

    Tip - Review the automatic snapshot script that is included in this blog: http://blogs.sun.com/timf/entry/zfs_automatic_for_the_people.


For more information:

Labels

osoladmin osoladmin Delete
task task Delete
filesystem filesystem Delete
zfs zfs Delete
snapshot snapshot Delete
adding adding Delete
admin admin Delete
sundoc sundoc Delete
smallsiteadmin smallsiteadmin Delete
singleadmin singleadmin Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact