Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for File Selection, Added Support for Windows zipping #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions BackupScript_v2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,16 @@ if ($PreCheck) {

foreach ($Backup in $FinalBackupdirs) {

$Files = Get-ChildItem -LiteralPath $Backup -recurse -Attributes D+!ReparsePoint, D+H+!ReparsePoint -ErrorVariable +errItems -ErrorAction SilentlyContinue |
$Files1 = Get-ChildItem -LiteralPath $Backup -recurse -Attributes D+!ReparsePoint, D+H+!ReparsePoint -ErrorVariable +errItems -ErrorAction SilentlyContinue |
ForEach-Object -Process { Add-Member -InputObject $_ -NotePropertyName "ParentFullName" -NotePropertyValue ($_.FullName.Substring(0, $_.FullName.LastIndexOf("\" + $_.Name))) -PassThru -ErrorAction SilentlyContinue } |
Where-Object { $_.FullName -notmatch $exclude -and $_.ParentFullName -notmatch $exclude } |
Get-ChildItem -Attributes !D -ErrorVariable +errItems -ErrorAction SilentlyContinue | Where-Object { $_.DirectoryName -notmatch $exclude }
#$BackupDirFiles.Add($Backup, $Files)

$Files+= Get-ChildItem -LiteralPath $Backup |
$Files2= Get-ChildItem -LiteralPath $Backup |
ForEach-Object -Process { Add-Member -InputObject $_ -NotePropertyName "ParentFullName" -NotePropertyValue ($_.FullName.Substring(0, $_.FullName.LastIndexOf("\" + $_.Name))) -PassThru -ErrorAction SilentlyContinue } |
Get-ChildItem -Attributes !D -ErrorVariable +errItems -ErrorAction SilentlyContinue
$Files = $files1 + $Files2
$BackupDirFiles.Add($Backup, $Files)


Expand Down Expand Up @@ -272,6 +273,18 @@ if ($BackUpCheck) {

if ($ZIP) {
Write-au2matorLog -Type INFO -Text "ZIP is on, so lets go"
if (!(Test-Path -Path $StagingPath)) {
try {
$null = New-Item -Path $StagingPath -ItemType Directory
Write-Verbose ("Path: ""{0}"" was created." -f$StagingPath)
}
catch {
Write-Verbose ("Path: ""{0}"" couldn't be created." -f $StagingPath)
}
}
else {
Write-Verbose ("Path: ""{0}"" already exists." -f $StagingPath)
}

if ($Use7ZIP) {
Write-au2matorLog -Type INFO -Text "We should use 7Zip for this"
Expand Down Expand Up @@ -305,7 +318,12 @@ if ($BackUpCheck) {
}
}
else {

Write-au2matorLog -Type Info -Text "Compress File"
$Zip = $StagingPath + ("\" + $BackupDestination.Replace($Destination, '').Replace('\', '') + ".zip")
Compress-Archive -Path $BackupDestination -DestinationPath $Zip
Write-au2matorLog -Type Info -Text "Move Zip to Destination"
Move-Item -Path $Zip -Destination $Destination
$ZIPCheck = $true
}
}
else {
Expand Down Expand Up @@ -365,4 +383,4 @@ if ($CountZip -gt $Versions) {

$Zip.FullName | Remove-Item -Recurse -Force

}
}