Restoring a subset of files or directories from a local fileset snapshot

You can restore a subset of files or directories from a local snapshot of an independent fileset 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 fileset 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 fileset 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 mmlsfileset device command to verify that the fileset status is linked and to determine the full path of the fileset.

    In the following example, all filesets are linked and the paths are in the third column.

    # mmlsfileset fs1
    
    Filesets in file system 'fs1':
    Name          Status   Path
    root          Linked   /gpfs/fs1
    nfs-ganesha   Linked   /gpfs/fs1/nfs-ganesha
    nfs-ganesha2  Linked   /gpfs/fs1/nfs-ganesha2
    nfs-ganesha3  Linked   /gpfs/fs1/nfs-ganesha3
    nfs-ganesha4  Linked   /gpfs/fs1/nfs-ganesha4
  4. Use the full path to the files and directories that you want to restore and the fileset path 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/
    Fileset path:           /gpfs/fs1/nfs-ganesha
    Truncated path:         /test1/
  5. Change the directory to the full snapshot path of the file or the directory to verify.

    The full snapshot path is:

    fileset_path/snapshot_directory/snapshot_name/truncated_path

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

    /gpfs/fs1/nfs-ganesha/.snapshots/fileset_test1/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