Skip to content

Voodoo File selection

Franco Corbelli edited this page Sep 2, 2023 · 3 revisions

Extracting files with zpaq can be confusing, therefore a bit of explanation
Backware compatibility with zpaq

The very first "thing" is that zpaq extract file to file, and files inside folder to folder
Translation: zpaq does not have a "simply" method to extract "pippo.txt" to the folder "pluto" (of course, zpaqfranz... yes :)
Instead, you can extract file "pippo.txt" to the FILE "pluto\minnie.txt"

Common examples, short version

A FILE to a FILE

zpaqfranz x versioni.zpaq prova/versione2.txt -to z:\ripristinato_versione2.txt

The file(s) inside a folder to a folder

zpaqfranz x versioni.zpaq prova/directory3 -to z:\newfolder

A file to a folder, creating subfolders as needed with the -only dirty trick

zpaqfranz x versioni.zpaq -only prova/filea.txt -to z:\thetree

Counter-example: this will NOT work

zpaqfranz x my-test-backup.zpaq '/Users/luke/some/path/file.png' -to /private/tmp/ -all

Why? Because it is an attempt to extract a FILE (file.png) to a FOLDER (/private/tmp)

Now... the "spiegone"... (working with versions)

Let's take this FreeBSD one as a real-world example file, and extract on Windows (the worst case)

root@aserver:/zroot/interna # zpaqfranz l replicata_ll3p.zpaq  -limit 10
zpaqfranz v58.7k-JIT-L,HW SHA1/2,(2023-07-24)
franz:-limit                                   10
replicata_ll3p.zpaq:
798 versions, 174.459 files, 56.289.378.748 bytes (52.42 GB)

 limit to first 10
- 2023-07-02 10:46:26                   0 d0777 /tank/d/
- 2023-07-24 16:41:00                   0 d0755 /tank/d/documenti/
- 2023-07-24 15:00:41                   0 d0777 /tank/d/documenti/ANNA/
- 2023-07-21 14:15:52                   0 d0777 /tank/d/documenti/ANNA/APPUNTI/
- 2023-04-13 16:06:51              96.256  0666 /tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
- 2018-10-18 14:43:20              58.368  0666 /tank/d/documenti/ANNA/APPUNTI/116 cpc.doc
- 2023-06-06 15:06:53              29.184  0666 /tank/d/documenti/ANNA/APPUNTI/1226 cc VALUTAZIONE EQUITATIVA.doc
- 2023-05-17 09:14:11              25.088  0666 /tank/d/documenti/ANNA/APPUNTI/1227 E DOPPIO NESSO CAUSALE - 2016.doc
- 2023-05-17 08:57:17              24.064  0666 /tank/d/documenti/ANNA/APPUNTI/1227 caso particolare CONCORSO VITTIMA SE CI SONO DUE CONCAUSE.doc
- 2023-03-01 10:51:31              46.080  0666 /tank/d/documenti/ANNA/APPUNTI/1227 cc.doc

              279.040 (272.50 KB) of 82.753.797.536 (77.07 GB) in 10 files shown
       56.289.378.748 compressed

20.068 seconds (000:00:20) (all OK)

We want to extract the second to last (the 24.064 bytes long) single file. This is a FILE to FILE

root@aserver:/zroot/interna # zpaqfranz x replicata_ll3p.zpaq "/tank/d/documenti/ANNA/APPUNTI/1227 caso particolare CONCORSO VITTIMA SE CI SONO DUE CONCAUSE.doc"  -to /tmp/ripristinato.doc
zpaqfranz v58.7k-JIT-L,HW SHA1/2,(2023-07-24)
replicata_ll3p.zpaq:
798 versions, 174.459 files, 56.289.378.748 bytes (52.42 GB)
Extract 24.064 bytes (23.50 KB) in 1 files (0 folders) / 16 T
21571: Path does not exists   /tmp/ripristinato.doc
21584: Getting free space for /tmp/


18.846 seconds (000:00:18) (all OK)

Here it is

root@aserver:/zroot/interna # ls -l /tmp/ripristinato.doc
-rw-rw-rw-  1 root  wheel  24064 May 17 10:57 /tmp/ripristinato.doc

Restore single file WITHOUT space-check (-space) (usually on *nix systems)

root@aserver:/zroot/interna # zpaqfranz x replicata_ll3p.zpaq "/tank/d/documenti/ANNA/APPUNTI/1227 caso particolare CONCORSO VITTIMA SE CI SONO DUE CONCAUSE.doc"  -to /tmp/ripristinato_nospace.doc -space
zpaqfranz v58.7k-JIT-L,HW SHA1/2,(2023-07-24)
franz:-space
replicata_ll3p.zpaq:
798 versions, 174.459 files, 56.289.378.748 bytes (52.42 GB)
Extract 24.064 bytes (23.50 KB) in 1 files (0 folders) / 16 T


19.448 seconds (000:00:19) (all OK)

If you want to get the X version (of this file) use -until X, NOT range X

Now you want to know "where" to find the versions of a file Here the -only *something dirty trick

We want to find (and get) different version of "something". Please note -only *something and -all. In this example the "115 cpc.doc". We have one file with multiple versions... but WHAT versions?

root@aserver:/zroot/interna # zpaqfranz l replicata_ll3p.zpaq -only "*/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc" -all 
zpaqfranz v58.7k-JIT-L,HW SHA1/2,(2023-07-24)
franz:-only                 */tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
--------------------------------------------------------------------------------------
franz:-all                                      4
replicata_ll3p.zpaq:
798 versions, 174.459 files, 56.289.378.748 bytes (52.42 GB)


- 2022-04-22 08:25:38              89.600  0666 0001|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
- 2022-11-25 10:01:13              92.672  0666 0153|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
- 2023-03-01 10:48:41              94.720  0666 0521|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
- 2023-04-13 16:06:51              96.256  0666 0695|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc

              373.248 (364.50 KB) of 373.248 (364.50 KB) in 4 files shown
       56.289.378.748 compressed

17.315 seconds (000:00:17) (all OK)

If you want the 2nd one you will do a x (blablabla) -until 153 (now we know there are 4 versions for file "115 cpc.doc", version 1, 153, 521, 695)

Of course, in "real world", I would prefer something "shorter" instead of the "full path". Look at the trick (the star) in *115 cpc.doc

root@aserver:/zroot/interna # zpaqfranz l replicata_ll3p.zpaq -only "*115 cpc.doc" -all 
zpaqfranz v58.7k-JIT-L,HW SHA1/2,(2023-07-24)
franz:-only                          *115 cpc.doc
--------------------------------------------------------------------------------------
franz:-all                                      4
replicata_ll3p.zpaq:
798 versions, 174.459 files, 56.289.378.748 bytes (52.42 GB)


- 2022-04-22 08:25:38              89.600  0666 0001|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
- 2022-11-25 10:01:13              92.672  0666 0153|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
- 2023-03-01 10:48:41              94.720  0666 0521|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc
- 2023-04-13 16:06:51              96.256  0666 0695|/tank/d/documenti/ANNA/APPUNTI/115 cpc.doc

              373.248 (364.50 KB) of 373.248 (364.50 KB) in 4 files shown
       56.289.378.748 compressed

Sidenote: running a range 153 extraction will take everything inside the version 153

root@aserver:/zroot/interna # zpaqfranz i replicata_ll3p.zpaq  |grep 00000153
00000153 2022-11-25 14:01:00  +00000139 -00000072 ->            9.538.876

or root@aserver:/zroot/interna # zpaqfranz i replicata_ll3p.zpaq -range 153:153

In this example there are 139 files (/folders) inside version 153; 72 previous files/folders no more present, ~9.5MB If you extract with -until 153 you will get (about) 50GB, every file until 153

Therefore range 153 is NOT just like -until 153, it is FROM 153 TO 153 I hope this is clear (!)

A bit of explanation on the heuristic for free space

On *nix there is NOT a simply way to "guess" what is the free space on a specific path. This is because the path can be inexistent (!), or "mounted" on nfs or whatever. The zpaqfranz try to "automagically" guess free space. Of course on *nix pippo.txt is no way a file, can be anything (a folder too), because extension does not exists. Aka: a MESS, but not my fault :)

Of course on Windows this is much easier to get the free space for x:\pippo\pluto.txt: it is (almost always) the free space of x:\

Recap: what on *nix for this example file

/tmp/restored/bar.md

is /tmp/restored/bar.md an existing folder? => yes, get free space, no => continue, split the path in "pieces", ad rebuild backward until the n-1 (take the "father" of /tmp/restored/bar.md, that should be /tmp/restored)

If /tmp/restored is a path that does exists, then zpaqfranz will "automagically" get the free space on /tmp/restored

If /tmp/restored does NOT exists, then zpaqfranz throws in the towel and "thinks" there is no space

In fact, it is true, a non existend path does not have free space

I didn't make further attempts, otherwise sooner or later you get to "/," and there the space is (generally) always present

In fact, it may happen that zpaqfranz refuses to execute some command, in complex situations, because it believes that the space is insufficient. zpaq, in this case, gives no warning: it executes and then silently fails midway.

Short version: if you are dealing with non-existent output paths, use -space to bypass any checks and voilà.

Versions: until and ranges

It's not over... maybe you're starting to understand why writing wikis isn't exactly a short and fun job...

to restore a single version the switch is -until. -range does a whole... range of other things.

-until means it restores a file (or all files) of version X (aka: all files not deleted from 1 to X)
-range extracts within a single folder many different subfolders, each with files in THAT version (like source versioning)

Translation: if in version 9 you have 100 files, and in version 10 you have 3 files, with -until 10 (I am simplifying, there are 1000 different cases, nothing is easy with zpaq) you will get a folder with 103 files

With range 10:10 you will get a folder with 3 files

Clone this wiki locally