Edit

Share via


Restore-AzDataLakeGen2DeletedItem

Restores a deleted file or directory in a filesystem.

Syntax

ReceiveManual (Default)

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

ItemPipeline

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Context

Azure Storage Context Object

Parameter properties

Type:IStorageContext
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DeletionId

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ReceiveManual
Position:2
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-FileSystem

FileSystem name

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ReceiveManual
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

Azure Datalake Gen2 Deleted Item Object to restore.

Parameter properties

Type:AzureDataLakeGen2DeletedItem
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ItemPipeline
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Path

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ReceiveManual
Position:1
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

AzureDataLakeGen2DeletedItem

IStorageContext

Outputs

AzureDataLakeGen2Item