github fcorbelli/zpaqfranz 65.23
Just about everything

one hour ago

zpaqfranz 65.23 -tar on Windows, images restored in order, and fixes

The theme of 65.23 is giving back exactly what was there:

  • -tar on Windows: the security of every file (owner, group, permissions, auditing,
    integrity label), the accounts by name, the hard links, the short names, the extended
    attributes. The same switch as on *nix, the same idea: keep what tar would keep;
  • an image restored to a .vhd is written in order, every byte once: good for hard
    disks, USB drives and NAS. And the restore of an image with many versions is much
    faster: on a .vhd of 199 GB with 24 versions, from about 65 minutes to less than 10;
  • four issues (374, 375, 376, 377) and the "files" of 0 bytes in WindowsApps.

In short:

  • New: -tar on Windows (a and x, as administrator: zpaqfranz runs itself
    elevated, as for -image). The whole story is in tar.md.
  • New: the app execution aliases of WindowsApps (winget.exe, python.exe...):
    a no longer ends with errors on them; with -tar they are kept, and x -tar makes
    them again.
  • An image to a .vhd: in order, by default. -ssd for the old way (by the
    threads, in any order, sparse).
  • Faster restore of images with many versions (and of x -stdout, pp, zip): a
    new cache of the decompressed blocks, which keeps only what is still to be written.
  • A .vhd bigger than the NTFS limit for sparse files (issue 374): it was "disk
    full?" with a disk almost empty.
  • Hashes of zeros written by zpaqfranz older than 65.1 (issue 375): tw said
    NOT AS STORED for files that were right.
  • -nojit was ignored on x86, and the JIT got a pair of swaps wrong (issue 376).
  • *-tar on nix: a new hard link in a later version came back as a copy (issue 377).

Part one, what is new, for the user

  1. -tar on Windows
  2. The app execution aliases (WindowsApps)
  3. An image to a .vhd: in order
  4. Images with many versions: a new cache
  5. A .vhd bigger than the NTFS limit (issue 374)
  6. Hashes of zeros, from zpaqfranz older than 65.1 (issue 375)
  7. -nojit, and a pair of swaps (issue 376)
  8. -tar on *nix: hard links across versions (issue 377)

1. -tar on Windows

Windows. The request came from a user who had to put back a game installed under
C:\Program Files, with its "strange" permissions: an installer that sets owners and ACLs
of its own, and a game that does not work any more if its files come back with the
permissions of the folder they land in. WIM (through wimlib) would keep them, but I do not
want another "world" inside zpaqfranz; an image of the volume with only that folder would
be a trap (every other file of the volume there, with its name and size, full of zeros).

What is needed is the data of the files plus what NTFS knows about each of them. That
is what -tar does on *nix, so the same switch does it on Windows:

zpaqfranz a z:\game.zpaq "c:\program files\game" -tar
zpaqfranz x z:\game.zpaq -tar -force
zpaqfranz x z:\game.zpaq -to d:\check -tar
zpaqfranz l z:\game.zpaq

What is kept, for every file and every folder of the version:

what given back
owner and group yes
the DACL, as it is (allowed and denied, inherited and explicit, the "protected" bit) yes, exactly: no inheritance pushed to the children
the SACL (auditing) and the integrity label yes
the accounts of a computer or a domain, by name by name when it exists here (-numeric: by SID, as stored)
hard links yes: one file, many names
short names (8.3) yes
extended attributes (WSL1 keeps the Linux owner and mode there) yes
  • Administrator only. The security of the files of the other users cannot be read by a
    normal user, and owners cannot be given back by one: half a table would be worse than
    none. From a normal prompt, a -tar and x -tar ask for the administrator rights by
    themselves, as -image does. Where that cannot happen: nothing is done, exit code 2.
  • Files that even the administrators cannot open (a DENY, the files of some programs) are
    read anyway: with -tar zpaqfranz opens them as backup software does.
  • It is stored as one more (virtual) file per version, VFILE-w-tar.txt, with the table
    of all the files of the archive at that version. A change of permissions alone (which
    on Windows does not change the date of the file) makes a new version with a new table,
    and nothing else; an a with nothing changed writes nothing.
  • l has a column TAR for the entries of the table (on Linux too).
  • x without -tar gives the data back as always, for anyone. zpaqfranz 65.22 and
    older, and zpaq 7.15, extract the table as a small text file.
  • On a volume that cannot keep something (exFAT, FAT, some network shares) there is one
    line for each thing
    it cannot keep, not an error for every file; exit code 1.
  • Long names. A hard link is made on a temporary name, 15 characters longer, then
    renamed: with names of 245-256 characters (there are some in WindowsApps) it failed
    without -longpath (64445! cannot make ... a hard link). Now every long name of
    -tar gets the \\?\ form by itself, with or without -longpath.

Everything else (the order of the work in x, the format of the table, the limits) is in
tar.md.

Thanks to the user of the forum who restored a whole Windows 11, from WinPE, with x -tar
of a pre-release, and posted the ten lines about the long names.

2. The app execution aliases (WindowsApps)

Windows. %LOCALAPPDATA%\Microsoft\WindowsApps is full of files of 0 bytes:
winget.exe, python.exe, wt.exe, ms-teams.exe... They are not files: each one is a
reparse point (IO_REPARSE_TAG_APPEXECLINK) with the package and the real exe inside, and
only CreateProcess knows how to open it. Every read fails, so up to 65.22 every a of a
whole profile ended with errors
("cannot access", exit code 2), with or without -tar. And
given back as empty files they would be worse than nothing: an empty winget.exe, first in
the PATH, breaks winget.

Now:

  • a never stores them as files, and says how many in one line (64462), exit code 0.
    Windows makes them again when the app is registered for the user.
  • a -tar keeps them in the table: the reparse point, attributes, date, permissions.
  • x -tar makes them again, with their date, attributes and permissions. One already
    there gets its permissions only; something else in its place is left alone (exit code 1),
    -force replaces it. -only, -not, -to, -until work as for the files.

An alias made again in another folder works: winget.exe --version from the -to folder
gives the version.

3. An image to a .vhd: in order

Windows. An image of the used clusters (a C: -image, ac) restored to a .vhd
(image ... -to x.vhd, or x of the archive, which builds the .vhd by itself) was written
by the threads, in any order, as a sparse file. On an SSD that is fine. On a hard disk, a
USB drive or a NAS it means a disk head that jumps all the time; and a .vhd too big to be
sparse (see issue 374) is first filled with
zeros, then written again: on my Windows 10 VM, 4.07 GB of zeros for a .vhd of 4.11 GB, almost
everything written twice.

From 65.23 the .vhd is written in order, by default: from the first byte to the last,
every byte once, never sparse (one line at the end says so, 62314). The free space is
checked first (62316, -space to bypass).

  • -ssd is the old way (by the threads, sparse while written): for SSD and NVMe.
  • A .vhdx, a .vmdk, a raw file or a drive (-to G:) were already written in order:
    nothing changes for them.
  • The .vhd is the same, to the byte, in order and with -ssd (and the same as 65.22).
  • My measure, an image of a volume of 4 GB on a Windows 10 VM: 13 s in order, 17 s the
    old way not sparse.

4. Images with many versions: a new cache

The restore of an image, and every command that writes files in order (x -stdout, the
.vhd, .vhdx, .vmdk and raw files of image, pp, zip, x -recover), keeps the
decompressed blocks in a cache, because a block can hold pieces of many files, or of many
places of the same disk. Up to 65.23 a block stayed in the cache, whole, until its last
piece was written. With many versions of a disk, the blocks of the old versions are needed a
little here and a little there, all over the disk: the cache was always full, the blocks read
ahead were thrown away, and the same blocks were decompressed again and again.

Now:

  • the cache keeps only the pieces still to be written, and a block leaves it with its last
    one;
  • when it is full, what goes out first is what will be needed latest (not the oldest);
  • when that is not enough, single pieces are put aside (read again later), not whole
    blocks: the pieces needed soon stay;
  • the blocks are read ahead by as many threads as there are;
  • Windows: the automatic size of the cache comes from the memory that can be
    committed, when it is less than the free RAM (before: from the free RAM only, then a
    "no memory" at about 17 GB on my PC, and the cache halved for the rest of the work).

The measure of my real case, an image restored to a .vhd of 199 GB, 24 versions, 16
threads, automatic cache:

time speed
65.23p (as 65.22) about 65 minutes 49-75 MB/s cache halved after a "no memory" (09190)
65.23q 588 s 324 MB/s cache 14.15 GB (the memory that can be committed)

And a test of mine, on a Windows 10 VM: a disk of 3 GB in 24 versions, 60 pieces of 256 KB
written again in every version (archive 2.1 GB, 142 blocks):

cache 65.23p (as 65.22) 65.23 decompressions (142 blocks)
64 MB 897 s 82 s 596
256 MB 110 s 34 s 213
automatic (enough for all) 14.1 s 13.6 s 142

The 199 GB were measured with 65.23q, the first half of the new cache; 65.23 also puts single
pieces aside (the test above, 64 and 256 MB), which helps when the cache is small.

With -verbose, one line (09849) says how it went: how many decompressions for how many
blocks, how many for pieces put aside and read again, how many blocks read ahead were thrown
away.

The output is the same, to the byte. With a cache big enough for everything nothing
changes: every block is decompressed once, as before.

5. A .vhd bigger than the NTFS limit (issue 374)

Windows. An image restored to a .vhd of 631 GB stopped with "disk full?" at 529 GB, with
1.3 TB free, after getting slower and slower. The .vhd was sparse while written (65.7o):
every fragment of zeros a hole. NTFS has a limit to the pieces of a sparse file, and a big
disk image reaches it.

  • Now a .vhd is sparse while written only up to 32 GB; above that, it is not sparse
    (39877 with -verbose). With the .vhd in order (section 3), the default, it is never
    sparse; the limit is for -ssd.
  • The error of a write says what the system said (error 112, disk full; 665, the
    limit of the file system), and the rest of that file is not written (56483, exit code 2):
    before, it was always "disk full?".

With 65.22: image ... -to x.vhd -nosparse gives the same .vhd, not sparse.

6. Hashes of zeros, from zpaqfranz older than 65.1 (issue 375)

tw (the test against the files on the disk) said DECOMPRESSED NOT AS STORED for half of
the files of an archive, and those files were right. l -checksum showed why:

XXHASH64B: 0000000000000000 CRC32: 00000000 #

zpaqfranz 64.x (I tried 64.1 and 64.9), for a file whose attributes only changed
(attrib +R, -A, +H; on *nix a chmod), wrote a new entry without reading the file: the
data of the version before, and hash and CRC-32 of zeros. 65.1 and later carry the hash
over, but a zero already written stays a zero, in every version after, and repack copies
it. A plain t skips a CRC-32 of zeros, and was right; tw compared it.

Now a hash of zeros (for a file that is not empty) is no hash, everywhere a hash is
compared:

  • where the file is compared to the disk byte by byte (tw with a folder, w -test -verify, t with a folder): it is checked that way, exit code 0;
  • where nothing checks the whole file (tw, v, t -verify, p, x -ramdisk, mount -test): a WARNING, exit code 1, and one line with the remedy (64457).

The remedy for such an archive: one more a of the same folder with -touch. It reads
again only the files without a usable hash, and writes their hash; on my test, a version of
2 KB. A plain t does not change.

02571 (NOT AS STORED) now says which check failed (hash XXHASH64B, CRC-32, only N bytes): without -verbose it was not possible to know.

7. -nojit, and a pair of swaps (issue 376)

  • -nojit was ignored on x86: a line of the code turned the JIT on again, always. Now
    -nojit wins (52863 with -debug): the ZPAQL is interpreted, and no memory is made
    executable (checked with strace on Linux: no anonymous writable and executable mapping).
  • The issue also pointed to the JIT itself: two equal swaps in a row (b<>a b<>a) were
    taken for one instruction, and one swap only was made. With a ZPAQL that does it
    (b= 65 b<>a b<>a out, made with zpaqd 7.15) the JIT gave AAAA..., the interpreter the
    right bytes. Now the JIT gives the same bytes as the interpreter.
    No method of zpaqfranz has two swaps in a row (I looked): no existing archive changes.
    Only hand-made ZPAQL could meet it.

8. -tar on *nix: hard links across versions (issue 377)

Linux, macOS, BSD, Solaris. The names of the same file seen by one a -tar are a group:
one is stored as the file, the others as "link to that name". A backup made every night meets
groups that change, and a new link added in a later version, with a name that sorted before
the old ones (d/new linked to d/s/file), became a group of its own: x -tar gave it back as
a separate copy.

Now:

  • a new link joins the group that is already in the archive;
  • x -tar makes the links after all the files, by groups: one name stays a file, every
    other one becomes a link to it, whatever the order of the names. A link whose first name is
    gone (deleted, or replaced by other data) is never linked to the wrong data;
  • two groups with the same data (deduplicated to the same fragments) stay two groups.

An archive already written by 65.22 or before, with such a link stored as a file, stays so: a
copy (until the file changes). More in tar.md.

Part two, the details, for power users

1. What can change for a script

  • a of a profile with WindowsApps (Windows): exit code 0 instead of 2; the aliases are
    not in the archive (one line, 64462).
  • -tar on Windows: a and x run themselves elevated, as -image; where they cannot
    (a session that cannot elevate, the "open" build from a normal prompt): exit code 2, no
    archive written, nothing extracted (64420, 64425). An archive written with it has one more
    virtual file per version. x -tar of an archive without the table: exit code 1 (64424).
  • image -to x.vhd, and x that builds the .vhd: in order, not sparse. The free space is
    checked first: not enough, exit code 2 (62316; -space to bypass). -ssd: the old way.
  • A write that fails (disk full, the limit of NTFS): exit code 2, the rest of that file not
    written, the error of the system in the line (56483).
  • Hashes of zeros (archives of zpaqfranz before 65.1): tw, v, t -verify, p, x -ramdisk, mount -test exit code 1 (before: 2, "NOT AS STORED"); tw and t with a folder,
    w -test -verify exit code 0.
  • -nojit on x86: now the ZPAQL is interpreted (slower to extract the methods with ZPAQL).
  • t archive folder with an archive of -tar of Windows: no more -internal for the table
    and +external for the aliases.
  • *x -tar on nix: the hard links are made after all the files.

2. The switches

Switch What
a -tar, x -tar (Windows) the security, the accounts, the hard links, the short names and the extended attributes of every file; administrator, elevated by itself
x -tar -numeric (Windows too) the SIDs as stored, not looked for by name
image -ssd the .vhd written by the threads, in any order, sparse (the way of 65.22)
image -space (with a .vhd) no check of the free space
-nojit now honored on x86 too
a -touch (not new) the remedy for the hashes of zeros of issue 375

3. The messages

Code When
02571! NOT AS STORED: now says which check (hash, CRC-32, size)
09849 -verbose: decompressions for blocks, pieces put aside, read ahead thrown away
09851 -verbose (Windows): the cache from the memory that can be committed
09529 -debug: a block wanted by the main thread taken whole into the cache
39877 -verbose: a virtual disk above 32 GB, not sparse while written
52863 -debug: -nojit, the JIT stays off
56483! a write that failed, with the error of the system: the rest of the file not written
62314-62321 the .vhd in order: the line at the end, the pieces, the free space, the errors
96456 x builds the .vhd, in order
64420!-64429! -tar on Windows: administrator, the table, the security given back
64440-64446 -tar on Windows: accounts by name, hard links
64447 l: the index read as well, for the column TAR
64450-64456 -tar on Windows: short names, extended attributes, a volume that does not keep something
64457$-64461$ hashes of zeros (issue 375): the remedy, tw, v, p
64462-64467 the app execution aliases

Part three, for developers

1. Known limits

  • -tar on Windows does not keep the alternate data streams (-forcewindows, as always),
    EFS, the compression and sparse flags. A folder that denies the listing even to the
    administrators is not seen by the scan, with or without -tar. The rest is in
    tar.md.
  • The NTFS limit of issue 374 was not reproduced here (it needs a sparse file of hundreds of
    GB): 32 GB is a limit on the safe side.
  • In order, with many versions, the jumps are in the reading of the archive instead of in
    the writing: the new cache is what keeps them few. The memory that can be committed is used
    on Windows only.
  • The hashes of zeros stay in the archive: -touch writes the right ones in a new version.
  • An archive of 65.22 with the new link of issue 377 stored as a file cannot be repaired.

Final word

The -tar switch on Windows is not magic, and not perfect, and does NOT want to

It's an improvement, not the "final word" on restoring strange NTFS things
A more extensive "whatever-support" is underway for the very next release BUT do NOT expect something like DISM-wim
If you like it, use it. That's all

Download zpaqfranz

Don't miss a new zpaqfranz release

NewReleases is sending notifications on new releases.