清除Linux应用服务上的文件,需要排除文件夹

问题描述 投票:0回答:1

我想在部署之前删除应用程序服务上的文件,以确保存在最新文件。但是,我需要排除一个文件夹。

我已将

-not -path
添加到正在尝试排除该文件夹的内容中。然而,
webroot/uploads
中的文件仍在删除中,并未排除。

$bodyToPOST = @{  
    command = "find . -mindepth 1 -delete -not -path `"/home/site/wwwroot/webroot/uploads/*`""  
    dir = "/home/site/wwwroot"  
}  

# Splat all parameters together in $param  
$param = @{  
    # command REST API url  
    Uri = "https://$WebAppName.scm.omited.appserviceenvironment.net/api/command"  
    Headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}  
    Method = "POST"  
    Body = (ConvertTo-Json $bodyToPOST)  
    ContentType = "application/json"  
}  
# Invoke REST call  
Invoke-RestMethod @param 

如何更改此脚本以从删除命令中排除文件夹

webroot/uploads

bash azure powershell azure-web-app-service
1个回答
0
投票

团队中的某人解决了这个问题,为了完整性而发布。

本质上,

-not -path
被替换为
!

$bodyToPOST = @{  
    command = "find . -mindepth 1 -delete ! ""/home/site/wwwroot/webroot/uploads/*"""  
    dir = "/home/site/wwwroot"  
}
© www.soinside.com 2019 - 2024. All rights reserved.