Editar

Compartilhar via


Restore-AzDataLakeGen2DeletedItem

Restores a deleted file or directory in a filesystem.

Syntax

Restore-AzDataLakeGen2DeletedItem
       [-FileSystem] <String>
       [-Path] <String>
       [-DeletionId] <String>
       [-AsJob]
       [-Context <IStorageContext>]
       [-DefaultProfile <IAzureContextContainer>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Restore-AzDataLakeGen2DeletedItem
       -InputObject <AzureDataLakeGen2DeletedItem>
       [-AsJob]
       [-Context <IStorageContext>]
       [-DefaultProfile <IAzureContextContainer>]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

Description

The Restore-AzDataLakeGen2DeletedItem cmdlet restores a deleted file or directory in a filesystem in an Azure storage account. This cmdlet only works if Hierarchical Namespace is enabled for the Storage account. This kind of account can be created by run "New-AzStorageAccount" cmdlet with "-EnableHierarchicalNamespace $true".

Examples

Example 1: List all deleted files or directories from a Filesystem, and restore them by pipeline

$items = Get-AzDataLakeGen2DeletedItem -FileSystem "filesystem1" 
$items

   FileSystem Name: filesystem1

Path                 DeletionId           DeletedOn            RemainingRetentionDays
----                 ----------           ---------            ----------------------
dir0/dir1/file1      132658816156507617   2021-05-19 07:06:55Z 3                     
dir0/dir2            132658834541610122   2021-05-19 07:37:34Z 3                    
dir0/dir2/file3      132658834534174806   2021-05-19 07:37:33Z 3   

$items | Restore-AzDataLakeGen2DeletedItem 

   FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group               
----                 -----------  ------          ------------         -----------  -----                -----               
dir0/dir1/file1      False        1024            2021-05-19 07:06:39Z rw-r-----    $superuser           $superuser          
dir0/dir2            True                         2021-05-19 07:06:37Z rwxr-x---    $superuser           $superuser          
dir0/dir2/file3      False        1024            2021-05-19 07:06:42Z rw-r-----    $superuser           $superuser

This command lists all deleted files or directories from a Filesystem, the restore all of them by pipeline.

Example 2: Restore an single file with path and DeletionId

Restore-AzDataLakeGen2DeletedItem -FileSystem "filesystem1"  -Path dir0/dir1/file1 -DeletionId 132658838415219780

FileSystem Name: filesystem1

Path                 IsDirectory  Length          LastModified         Permissions  Owner                Group               
----                 -----------  ------          ------------         -----------  -----                -----               
dir0/dir1/file1      False        1024            2021-05-19 07:06:39Z rw-r-----    $superuser           $superuser

This command restores an single file with path and DeletionId. The DeletionId can be get with 'Get-AzDataLakeGen2DeletedItem' cmdlet.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Context

Azure Storage Context Object

Type:IStorageContext
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DeletionId

The deletion ID associated with the soft deleted path. You can get soft deleted paths and their assocaited deletion IDs with cmdlet 'Get-AzDataLakeGen2DeletedItem'.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-FileSystem

FileSystem name

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-InputObject

Azure Datalake Gen2 Deleted Item Object to restore.

Type:AzureDataLakeGen2DeletedItem
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Path

The deleted item path in the specified FileSystem that should be restore. In the format 'directory/file.txt' or 'directory1/directory2/'

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

AzureDataLakeGen2DeletedItem

IStorageContext

Outputs

AzureDataLakeGen2Item