kevinoffsite
New Member
- Joined
- Mar 21, 2017
- Messages
- 9
$prodShare = "\\fileserver\share"
$externalBackup = "\\backupserver\share"
$prodFileList = Get-ChildItem -Path $prodShare -Recurse -File
$externalBackupFileList = Get-ChildItem -Path $externalBackup -Recurse -File
foreach ($backupFile in $externalBackupFileList)
{
$found =$false
foreach ($prodFile in $prodFileList)
{
$tempProdName = $prodFile.FullName.Replace($prodShare,'')
$tempbackupName = $backupFile.FullName.Replace($externalBackup,'')
if($tempProdName -like $tempbackupName)
{
$found = $true
break
}
}
if((-not $found))
{
$missingFileList += @($backupFile)
}
}...
Not super efficient with PS, and we are talking 2TB of data...A simple powershell script could handle this
sudo code
- Grab list of prod_share files only something like $prodFiles = Get-ChildItem -Path <prodshare> -Recurse -File
- Grab list of externalBackup $externalFiles = Get-ChildItem -Path <externalBackupshare> -Recurse -File
- Compare the lists if file is in externalBackup and not prod add the file object to an array
- Run through the $missingFile array and copy each file over
$prodShare = "\\fileserver\share"
$externalBackup = "\\backupserver\share"
$prodFileList = Get-ChildItem -Path $prodShare -Recurse -File
$externalBackupFileList = Get-ChildItem -Path $externalBackup -Recurse -File
foreach ($backupFile in $externalBackupFileList)
{
$found =$false
foreach ($prodFile in $prodFileList)
{
$tempProdName = $prodFile.FullName.Replace($prodShare,'')
$tempbackupName = $backupFile.FullName.Replace($externalBackup,'')
if($tempProdName -like $tempbackupName)
{
$found = $true
break
}
}
if((-not $found))
{
$missingFileList += @($backupFile)
}
}
foreach($file in $missingFileList)
{
$newFileName = "$prodShare$($file.FullName.Replace($externalBackup,''))"
Copy-Item -Path $file.FullName -Destination $newFileName
}