Restoring a subset of files or directories from a local file system snapshot

You can restore a subset of files or directories from a local snapshot of a file system in case of accidental deletion.

Ensure the following before you begin:

  • You have the full path to the files or directories that you want to restore. The path must include the file system to which these files or directories belong.
  • You know which snapshot contains the files or directories that you want to restore.
  • You have created a restore directory to which these files or directories are to be restored to avoid accidentally overwriting files or directories.

For information on how to create and maintain snapshots, see Creating and maintaining snapshots of file systems

Use these steps to restore files or directories from a local file system snapshot.
  1. Use the mmlssnapshot device command to list the snapshots in the file system and make a note of the snapshot that contains the files and directories that you want to restore.

    device is the name of the file system.

    # mmlssnapshot fs1
    
    Snapshots in file system fs1:
    Directory        SnapId  Status   Created                   Fileset
    fileset_test1    1       Valid    Mon Mar 23 09:20:37 2015  nfs-ganesha
    filesystem_test2 2       Valid    Mon Mar 23 11:12:59 2015
  2. Use the mmsnapdir device command to obtain the name of the snapshot directory for the file system snapshot that you have identified.

    In the following example, the fileset snapshot directory is called .snapshots.

    # mmsnapdir fs1
    
    Fileset snapshot directory for "fs1" is ".snapshots" (root directory only)
    Global snapshot directory for "fs1" is ".snapshots" in root fileset
  3. Use the mmlsfs device -T command to determine the default mount point of the file system.

    In the following example, the default mount point is /gpfs/fs1.

    # mmlsfs fs1 -T
    
    flag  value      description
    ----  ------     ---------------
    -T    /gpfs/fs1  Default mount point
  4. Use the full path to the files and directories that you want to restore and the default mount point that you have determined to obtain the truncated path to the files and directories.

    For example:

    Full path to the file:  /gpfs/fs1/nfs-ganesha/test1/
    Default mount point:    /gpfs/fs1
    Truncated path:         /nfs-ganesha/test1/
  5. Change the directory to the full snapshot path of the file or the directory to verify.

    The full snapshot path is:

    filesystem_default_mountpoint/snapshot_directory/snapshot_name/truncated_path

    The full snapshot path using examples in the preceding steps is:

    /gpfs/fs1/.snapshots/filesystem_test2/nfs-ganesha/test1/

  6. Do one of the following steps depending on whether you want to restore a file or a directory:
    • If you want to restore a file, use the following command:

      cp -p full_snapshot_path/file_name restore_directory

    • If you want to restore a directory, change the directory to the restore_directory and use the following command:

      tar -zcf tar_file_name full_snapshot_path/directory_name