empty dirs

Sep 26, 2016 at 1:23 PM
Hi Allan,
I try to backup with 7backup script but the empty dirs are not saved.
What can i do?
best regards

savino
Coordinator
Sep 26, 2016 at 5:12 PM
Edited Sep 26, 2016 at 5:12 PM
Hi savino and thank you for your feed back.

By default empty dirs are not saved. To force the save of empty dirs you must execute
7zBackup.ps1 [...] --emptydirs True
Sep 27, 2016 at 9:31 AM
Hy Anlan,
thank you for your quick response, but i execute the command .\7zBackup.ps1 --type full --selection selection.txt --destpath C:\backup --emptydirs True and an error " Err : Unknown argument True" occured. Without true it shows no errors but not results as well.
What can i try?
kind regards
Oct 5, 2016 at 10:08 AM
Hy Anlan
i think you are very busy, i've tested old release and i can say that the releases > of 7zBackup v. 1.10.3 Stable produce no results with the option --emptydirs
kind regards
Oct 14, 2016 at 10:31 PM
Hello uLinux, Anlan,

I have the same issue using the latest release v2.03 stable version. The empty folders are not archived even with the switch "--emptydirs" added to the 7zBackup,ps1 command. Also uLinux is correct, the "--emptydirs True" is not a valid switch syntax. It has to be "--emptydirs" by itself.

I spent some time reading the source code of the v2.03 7zBackup.ps1 file and I made the following changes to make the empty folders appear in the archive.

the original code starting at line 913
    # If it is an empty directory
If($scanThisPathForRecursion -and (!$childFiles.Count) -and ($BkKeepEmptyDirs -eq $True) -and !($childItemsScanErrors)) {

    # Older versions of 7zip require at least one file to save a folder
    # Newer versions will simply create the folder
    If ([int]$MyContext.SevenZBinVersionInfo.Major -le 9) { 
        # Try to drop a placeholder file and reload child items
        $childFile = New-Item (Join-Path -Path $thisFolder.RelativeName -ChildPath $MyContext.DummyFile) -type File
        If($?) { 
            $Counters.PlaceHolders += $childFile
            $SWriters.Inclusions.WriteLine([string](Join-Path -Path $thisFolder.RelativeName -ChildPath $childFile.Name))
        }
        Return
    } Else {
        $SWriters.Inclusions.WriteLine([string]$thisFolder.RelativeName)
        Return
    }

} 
modified code starting at line 913
    # If it is an empty directory
If($scanThisPathForRecursion -and ($childItems.Count -eq 0) -and ($BkKeepEmptyDirs -eq $True) -and !($childItemsScanErrors)) {

    # Older versions of 7zip require at least one file to save a folder
    # Newer versions will simply create the folder
    If ([int]$MyContext.SevenZBinVersionInfo.Major -le 9) { 
        # Try to drop a placeholder file and reload child items
        $childFile = New-Item (Join-Path -Path $thisFolder.RelativeName -ChildPath $MyContext.DummyFile) -type File
        If($?) { 
            $Counters.PlaceHolders += $childFile
            $SWriters.Inclusions.WriteLine([string](Join-Path -Path $thisFolder.RelativeName -ChildPath $childFile.Name))
        }
        Return
    } Else {
        $SWriters.Inclusions.WriteLine([string]$thisFolder.RelativeName)
        Return
    }

}
The only changes I made are the 2nd condition changed from (!$childFiles.Count) to ($childItems.Count -eq 0)

Please verify if this is one of the viable solutions.

Best regards
Coordinator
Oct 15, 2016 at 9:47 AM
Yep ... shame on me.
hvdz890 is right ... will correct.
Coordinator
Nov 12, 2016 at 5:11 PM
All fixed in new release 2.0.4