za3k / qr-backup

Paper backup of files using QR codes
Other
129 stars 12 forks source link

Support for docker #57

Closed vonProteus closed 1 month ago

vonProteus commented 1 month ago

i tried to run it on mac (arm) and it has some problems

so i pack it into a docker image https://github.com/vonProteus/qr-backup/tree/docker

but its has some problem which i cant resolve by my self

when i run

docker run -v $(pwd):$(pwd) --workdir=$(pwd) --rm -ti vonproteus/random-images:qr-backup --verbose --encrypt generate Dockerfile ```shell INFO: Original arguments were: [] INFO: Command arguments parsed. Equivalent command: qr-backup --qr-version 10 --dpi 300 --scale 5 --error-correction L --page 500 600 --compress --filename Dockerfile --encrypt ??? --use-erasure-coding --shuffle Dockerfile.qr.pdf INFO: read file Dockerfile (sha b4804b4f2e83478f041b48aa5c84e1025e909d9e9913a95ac9a1a815fce5bb0f, 0.806KB) Your secret encryption passphrase is: physical lawn warrior alter rice wave boring mad Back this up somewhere secure or you will be unable to access your data INFO: generate_erasure: perform self-test INFO: generate_erasure: deleted first few symbols, restore works fine INFO: Restore command is: sort -u | grep "^N" | cut -c6- | base64 -d | tail -c +5 | head -c 504 | gpg --decrypt | gunzip INFO: 6 qr codes (at version 10) total INFO: QR code (including label) is: 285x285px INFO: Page is: 2083x2500px INFO: 6 x 6 qr codes (at version 10) per page. 1 pages total INFO: 508 compressed bytes in 1 page(s). 0.81KB/page including compression, 0.51KB/page without compression INFO: 4.84KB/page theory without compression) INFO: Outputting: Dockerfile.qr.pdf INFO: Restore command used in Linux CLI test: sort -u | grep "^N" | cut -c6- | base64 -d | tail -c +5 | head -c 504 | gpg --decrypt --no-symkey-cache --batch --passphrase 'physical lawn warrior alter rice wave boring mad' | gunzip INFO: self-test using files INFO: Performing linux CLI restore check... INFO: Linux CLI command was: convert -density 600 Dockerfile.qr.pdf tif:- | zbarimg --raw -q -Sdisable -Sqrcode.enable - | sort -u | grep "^N" | cut -c6- | base64 -d | tail -c +5 | head -c 504 | gpg --decrypt --no-symkey-cache --batch --passphrase 'physical lawn warrior alter rice wave boring mad' | gunzip | cmp Dockerfile INFO: Linux CLI exit code was: False INFO: Test command was: convert -density 600 Dockerfile.qr.pdf tif:- | zbarimg --raw -q -Sdisable -Sqrcode.enable - | wc -l INFO: Performing qr-backup restore check... INFO: Self-test command was: ['python3', '/usr/local/bin/qr-backup', '--restore', '--sha256', 'b4804b4f2e83478f041b48aa5c84e1025e909d9e9913a95ac9a1a815fce5bb0f', 'Dockerfile.qr.pdf', '--encrypt', 'physical lawn warrior alter rice wave boring mad'] INFO: Self-test exit code was: False INFO: Read 0/6 qrs (0.00%) ERROR: !!Automatic digital restore verification FAILED (self-test). This indicates a bug in qr-backup. Please report this to the author at https://github.com/za3k/qr-backup/issues ```

i get an error

but backup file looks ok to me Dockerfile.qr.pdf

when i try to restore it i get another error

docker run -v $(pwd):$(pwd) --workdir=$(pwd) --rm -ti vonproteus/random-images:qr-backup --restore --verbose Dockerfile.qr.pdf ```shell CRITICAL: WARNING: Printing file directly to interactive stdout. You probably want to run qr-backup >filename. Press Control-C to exit. INFO: image restore selected INFO: Converting to tif: Dockerfile.qr.pdf INFO: [convert stdout] b'' INFO: [convert stderr] b"convert-im6.q16: no images defined `/tmp/tmpn5bt87fc.tif' @ error/convert.c/ConvertImageCommand/3229.\n" CRITICAL: Conversion from PDF to TIF failed: Dockerfile.qr.pdf ```

when i try to run tests i get

docker run --workdir=/src --entrypoint=/bin/sh --rm -ti vonproteus/random-images:qr-backup -c "make test" ```shell python3 tests/test.py backup-regression 100b zeros 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: 13267006e3f8d34eb55e694481b6721eb2d4657c8dc7d7dac0c7d5a095fa6ab8 != ed26a865598955e799e310c3bb38549b68ea951a11af2ae9c3a887ab427e9288 incorrect-restore 100b zeros 1s command: python3 qr-backup --restore - too-fast 100b zeros 1s, <2^-4 backup-regression default options 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --dpi 300 --compress --erasure-coding --filename file --instructions page --num-copies 1 --output - --page 500 600 --qr-version 10 --scale 5 --shuffle result: 13267006e3f8d34eb55e694481b6721eb2d4657c8dc7d7dac0c7d5a095fa6ab8 != ed26a865598955e799e310c3bb38549b68ea951a11af2ae9c3a887ab427e9288 incorrect-restore default options 1s command: python3 qr-backup --restore - too-fast default options 1s, <2^-4 backup-regression --no-compress 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --no-compress result: d361cda72bc477e721dde1ad8553a27d869b2dd48ef95d4869932ab3d94003c5 != af282809a01c4a163372f9237b07e36e779f039c383a9b324d149674b07cfb40 incorrect-restore --no-compress 1s command: python3 qr-backup --restore - too-fast --no-compress 1s, <2^-4 backup-regression --dpi 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --dpi 50 result: a7623a78815e11e41ed595dc6a8608e81f80124530bf4e8f97729318ac37991a != 0b9bab6921925979a3c4e88e59e51e6d63b5c0830a7c0ff77a7aad2475b4502c incorrect-restore --dpi 1s command: python3 qr-backup --restore - too-fast --dpi 1s, <2^-4 incorrect-restore --encrypt 1s command: python3 qr-backup --restore - --encrypt PASSWORD too-fast --encrypt 1s, <2^-4 incorrect-restore --encrypt-print-passphrase 1s command: python3 qr-backup --restore - --encrypt PASSWORD too-fast --encrypt-print-passphrase 1s, <2^-4 backup-regression --no-erasure-coding 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --no-erasure-coding result: ceda967c90502525f2e89b490237ef1ef16e5170bf778e749603d8f8106bb267 != c0a08d86b71280517d1ff3cf56c7bbb998fdece72e3f996546877b1ca1df485e incorrect-restore --no-erasure-coding 1s command: python3 qr-backup --restore - too-fast --no-erasure-coding 1s, <2^-4 backup-regression --error-correction L 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --error-correction L result: 3ca53c6bbf241a256d5869df8029ce575fdf1dd99869867c8771429c41f0897b != b1043946459cb7367baa4214edd062671f6c78a6937e0287c7ca2f832ceacece incorrect-restore --error-correction L 1s command: python3 qr-backup --restore - too-fast --error-correction L 1s, <2^-4 backup-regression --error-correction Q 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --error-correction Q result: 10bcc52af927c540a2bfd25cbbee75d7020272a216ce26cfafce1c609d6ad866 != a3efa49a970267cadb5d4dd3f0fcb67d69bc5069d51809f16754f06dc74de286 incorrect-restore --error-correction Q 1s command: python3 qr-backup --restore - too-fast --error-correction Q 1s, <2^-4 backup-regression --error-correction H 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --error-correction H result: c185198c6b2e7503fd37e5f3463740ad16da55813fd2b3dc0b1e2cbbc2ee2bb6 != 2caa340d11e530a7e770caf71a3d0efee85defe4f5aec315b9c00bda6658089f incorrect-restore --error-correction H 1s command: python3 qr-backup --restore - too-fast --error-correction H 1s, <2^-4 backup-regression --filename 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --filename TEST_FILENAME result: 4080ba19c3fcb0d88b8ec24e596e17998c30ea67cb3f2f1f49e3d2729219efef != 9a61e8185bfcf9b9c3d2901baea7430b448ed6e0e03759619045b61a38e29d4e incorrect-restore --filename 1s command: python3 qr-backup --restore - too-fast --filename 1s, <2^-4 backup-regression --instructions both 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --instructions both result: 6c715ba4afb5e6506254d5203b4d6c15b85fb122c502100ef84b73c9747b0ed4 != 6ad4661009ebda82e6618f81caaa2fa43df1ac7d4a938ef3a7818588a8cc3c6b incorrect-restore --instructions both 1s command: python3 qr-backup --restore - too-fast --instructions both 1s, <2^-4 backup-regression --instructions cover 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --instructions cover result: a9c740b1e4f770c0592a459a334effecf3bf0185ae656a5b6f173ebec098e76d != 452f3e23a7f71e1f9d1892d64910ff185f12799dc5093f29f085fe003bd69629 incorrect-restore --instructions cover 1s command: python3 qr-backup --restore - too-fast --instructions cover 1s, <2^-4 backup-regression --instructions none 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --instructions none result: 9d5075645825c8087932a4753b0d4532f524680d502ee05b923c3d2d801141cf != c66fdd3e1a7fd3107f95daab2d07b65cfe5e4b679fef5b2dca73d004baee494d incorrect-restore --instructions none 1s command: python3 qr-backup --restore - too-fast --instructions none 1s, <2^-4 backup-regression --note (1) 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --note A result: 9f33f3de17e50e17780d6f2a8de4ad2d90bdda42a2f21a46f9ab3a0ebe62795b != 6cdf1ba777d47c68a92eb1f49f35b8bd186431e639d560b6f1bacee2a3ee03e3 incorrect-restore --note (1) 1s command: python3 qr-backup --restore - too-fast --note (1) 1s, <2^-4 backup-regression --note (2) 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --note A --note B result: 83b9945bd5c699528c13c4d36331df69a9112c402b0e515e7bcd60c0cabbc6b5 != 8085233b46a4c61477fae0e9abea0c7f751f829763eaeaee36a3de3e6046ad9d incorrect-restore --note (2) 1s command: python3 qr-backup --restore - too-fast --note (2) 1s, <2^-4 backup-regression --num-copies 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --num-copies 3 result: d93d81c3e8cc411448eac8c847a04e99efe550552324890ccea92f3e29af39ae != 7c705557390d346eb87bb08ea437ed8a42198b2ceeea296fbf891c1b20c695e2 incorrect-restore --num-copies 1s command: python3 qr-backup --restore - too-fast --num-copies 1s, <2^-4 backup-regression --page 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --page 100 200 result: 5ad1401d6eefbc68b0b646080a93a4f9425e2cebc733d583a4d597f416353d7d != 8b3cfdb1e5b07ec72c552f6ab95ab39c04d419d23afad31b7b78fda395d435e9 incorrect-restore --page 1s command: python3 qr-backup --restore - backup-regression --qr-version 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --qr-version 15 result: f2f6fadba57db5f44afdc4ae2802ce74c9277dfe0e4f145ad7c695a2226cbe9d != 1add32b1947948f32d6baab525a5621930a46cc2438012953b8992e930adea70 incorrect-restore --qr-version 1s command: python3 qr-backup --restore - too-fast --qr-version 1s, <2^-4 backup-regression --scale 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --scale 10 result: fb60db5e1057d2191efc2e4a326d0a658f20e6a26119569205e459db7714642c != 4cc28752038be68e69bd9b52ef3ab1aa310ce216be7af86e5cdfa0582c61e9b1 incorrect-restore --scale 1s command: python3 qr-backup --restore - too-fast --scale 1s, <2^-4 backup-regression --no-shuffle 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --no-shuffle result: e84a26dd07c20373555dc195c8408702c7c307b28926e8f6f83c138de3dc5edb != 10559366e0b5590660838b5c7893f1a3fb22fefab39e943dc667cfc34c82d6c9 incorrect-restore --no-shuffle 1s command: python3 qr-backup --restore - too-fast --no-shuffle 1s, <2^-4 backup-regression 1K zeros 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: 25f5c4f34222fd67ddeffc7e5c06e252cc7bcb3e09f9f3724dcfad429c92e4b9 != 0f5da5bd812284e6a18f974af3187b442c4fed0cc595c231b96a5bdd4b0cd965 incorrect-restore 1K zeros 1s command: python3 qr-backup --restore - too-fast 1K zeros 1s, <2^-4 backup-regression 10K zeros 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: fdbf23f9dd8255f7897e8284a1c345e476118449df3772445846f3108017a14a != 68328734a28dcc05d9884641c591f0592920f5efb861062a17877a0557400e0c incorrect-restore 10K zeros 1s command: python3 qr-backup --restore - too-fast 10K zeros 1s, <2^-4 backup-regression 100K zeros 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: e00aad4dc175e5002c1fb22d111a40a8aec6546787db587f16e780b086c78ead != b3fa3458bdf24863d1450d0c3b407c2b7f4847c2dc9d841b9a88c20e89f720b1 incorrect-restore 100K zeros 1s command: python3 qr-backup --restore - too-fast 100K zeros 1s, <2^-4 backup-regression 100b random 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: 669224da5b170977bd247b0c51716c291cfec61669426d116517f7b7d3638ad0 != 59512f3c17bdeb122b652c4fb130e4094f21159d965bea73847177ac51237417 incorrect-restore 100b random 1s command: python3 qr-backup --restore - too-fast 100b random 1s, <2^-4 backup-regression 1K random 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: 494eaff0083437b15fb7c69ade3a0b36f184e8e9baed64af97f9bf6f32ee0bb0 != 7f9aeeea1ba41b6f6044bdeda64e87b626942dbead4ba409bc1a3f2195b91a2a incorrect-restore 1K random 1s command: python3 qr-backup --restore - too-fast 1K random 1s, <2^-4 backup-regression 10K random 2s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: 9c6cb2e2437b125bf59d32290d03c32886ef1f3f894768569a67d109234d05fa != 63222f94ba30f2e887deb0a85ab032d0fe5c6e87737552d5b151c0b0556888b0 too-fast 10K random 2s, <2^1 incorrect-restore 10K random 1s command: python3 qr-backup --restore - too-fast 10K random 1s, <2^-3 backup-regression 50K random 7s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 result: 13c110821942ecf6ed476af836cf786b528dc3a1bc10c6a5ea3523c81f47d6c6 != 4198a84b9a35f62108c26bd698295d1937d7257382e47db6f79ac8c8613a29a4 too-fast 50K random 7s, <2^3 incorrect-restore 50K random 1s command: python3 qr-backup --restore - too-fast 50K random 1s, <2^-3 backup-regression 1K zeros, self-check 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --no-skip-checks result: 25f5c4f34222fd67ddeffc7e5c06e252cc7bcb3e09f9f3724dcfad429c92e4b9 != 0f5da5bd812284e6a18f974af3187b442c4fed0cc595c231b96a5bdd4b0cd965 too-fast 1K zeros, self-check 1s, <2^-2 incorrect-restore 1K zeros, self-check 1s command: python3 qr-backup --restore - too-fast 1K zeros, self-check 1s, <2^-4 backup-regression 1K random, self-check 1s command: python3 qr-backup --skip-checks - --backup-date 2022-09-22 --no-skip-checks result: 494eaff0083437b15fb7c69ade3a0b36f184e8e9baed64af97f9bf6f32ee0bb0 != 7f9aeeea1ba41b6f6044bdeda64e87b626942dbead4ba409bc1a3f2195b91a2a too-fast 1K random, self-check 1s, <2^-1 incorrect-restore 1K random, self-check 1s command: python3 qr-backup --restore - too-fast 1K random, self-check 1s, <2^-4 58 failures make: *** [Makefile:39: test] Error 1 ```
za3k commented 1 month ago

Thanks for giving it a try on mac! You're the first person to do so. Would you mind posting the requirements and issues you run into on OS X as a separate bug, if you have time?

I looked at the pdf, and I can confirm I can read all 6 QR codes. It looks like it's the restore process which is broken.

From your logs, this is the command is being used to read the QRs:

convert -density 600 Dockerfile.qr.pdf tif:- | zbarimg --raw -q -Sdisable -Sqrcode.enable - | wc -l

(I notice INFO: Linux CLI exit code was: False in the logs. That should really be a numeric exit code--that's a small logging bug, looks like.)

Can you open an interactive bash shell using Docker, run each of these two steps manually, and see which is failing and with what output? It looks like you've attempted to install them and change the policy file, which is a good start.

convert -density 600 Dockerfile.qr.pdf Dockerfile.tif
zbarimg --raw -q -Sdisable -Sqrcode.enable Dockerfile.tif
vonProteus commented 1 month ago

this docker image is public available on docker hub and when i try to run convert -density 600 Dockerfile.qr.pdf Dockerfile.tif in container i get

convert-im6.q16: no images defined `Dockerfile.tif' @ error/convert.c/ConvertImageCommand/3229.

and i found undocumented dependency ghostscript

vonProteus commented 1 month ago

now everything work if you want you can merge my docker solution

za3k commented 1 month ago

Thanks for your work. I'd be happy to merge it.

And I'll make sure to document that ghostscript is required.