Restoring a subset of files or directories from local snapshots using the sample script

You can restore a subset of files or directories from local snapshots using a sample script in case of accidental deletion.

  • The mmcdpsnapqueryrecover sample script only works on the Linux® operating system.

  • The sample script retrieves files or directories from all file system and fileset snapshots on the system and presents a list of files that you can choose to restore.

  • Regular files are simply copied into the user-specified directory. If the user specifies a directory to be retrieved, the directory is copied into the user-specified directory as a compressed tar file.

  • Files and directories that contain spaces in their names can also be retrieved.

Use the mmcdpsnapqueryrecover sample script to restore files or directories from snapshots into the user-specified restorePath directory as follows.

  1. Use the following command to list all copies of a file or directory in a file system or fileset snapshot.
    /usr/lpp/mmfs/samples/ilm/mmcdpsnapqueryrecover.sh Device \
    --file-path fsPath --destination-dir restorePath

    Where:

    • device is the name of the file system.
    • file-path is the full file path.
    • destination-dir is the full path of the restore directory.
    For example, to get all copies of the file /gpfs0/gplssnapshot in the file system gpfs0 and with /opt as the restore directory, enter the following:
    /usr/lpp/mmfs/samples/ilm/mmcdpsnapqueryrecover.sh /dev/gpfs0 \
    --file-path /gpfs0/gplssnapshot --destination-dir /opt
    All copies of the specified file are listed as follows:
    Found regular file in filesystem snapshot: restorFiles1
    1) 5743 Jan 9 08:34 /gpfs0/.snapshots/restorFiles1/gplssnapshot
    
    Found regular file in filesystem snapshot: restorFiles3
    2) 5882 Jan 9 08:34 /gpfs0/.snapshots/restorFiles3/gplssnapshot
    
    Found regular file in filesystem snapshot: Restore1
    3) 5886 Jan 14 12:33 /gpfs0/.snapshots/Restore1/gplssnapshot
    
    Found regular file in filesystem snapshot: Restore2
    4) 5886 Jan 14 12:33 /gpfs0/.snapshots/Restore2/gplssnapshot
    
    Found regular file in filesystem snapshot: global1
    5) 5886 Jan 14 12:33 /gpfs0/.snapshots/global1/gplssnapshot
    
    Which copy of the file/directory (1-5) would you like to restore? 
  2. From the list, select the file that you want to restore by entering the corresponding number.
    For example:
    Which copy of the file/directory (1-5) would you like to restore? 2
    The copy number 2 is restored to the /opt directory.