ディレクトリを特定の形式に圧縮して作成した後、確認したいので、次の.tar.xz
ようなコマンドを作成しました。
tar --xz --create --verbose --verify --file myArchive.tar.xz /patch/to/my/dir
ただし、アーカイブが生成されないため、次の2行のエラーが発生します。
tar: Cannot verify compressed archives
try 'tar --help' or 'tar --usage' for more information.
tar.gz
代わりにフォーマットを試しましたが、tar.xz
結果はまったく同じでした。問題は何であり、解決策は何ですか?
答え1
tar マニュアルのセクション 9.8 は次のように述べています。
9.8 Verifying Data as It is Stored
==================================
`-W'
`--verify'
Attempt to verify the archive after writing.
This option causes `tar' to verify the archive after writing it.
Each volume is checked after it is written, and any discrepancies are
recorded on the standard error output.
Verification requires that the archive be on a back-space-able
medium. This means pipes, some cartridge tape drives, and some other
devices cannot be verified.
圧縮アーカイブはバックスペースを実行できないため、両方のオプションを混在させようとするとエラーが発生します。
次の段落では、--compare
これを使用する必要があると述べています。
One can explicitly compare an already made archive with the file
system by using the `--compare' (`--diff', `-d') option, instead of
using the more automatic `--verify' option. *Note compare::.
Note that these two options have a slightly different intent. The
`--compare' option checks how identical are the logical contents of some
archive with what is on your disks, while the `--verify' option is
really for checking if the physical contents agree and if the recording
media itself is of dependable quality. So, for the `--verify'
operation, `tar' tries to defeat all in-memory cache pertaining to the
archive, while it lets the speed optimization undisturbed for the
`--compare' option. If you nevertheless use `--compare' for media
verification, you may have to defeat the in-memory cache yourself,
maybe by opening and reclosing the door latch of your recording unit,
forcing some doubt in your operating system about the fact this is
really the same volume as the one just written or read.
The `--verify' option would not be necessary if drivers were indeed
able to detect dependably all write failures. This sometimes require
many magnetic heads, some able to read after the writes occurred. One
would not say that drivers unable to detect all cases are necessarily
flawed, as long as programming is concerned.
確認のために、--compare
次のことができます。
tar --xz --create --verbose --file myArchive.tar.xz /patch/to/my/dir
tar --compare --file myArchive.tar.xz /patch/to/my/dir