2

I have a huge uncompressed tar file (1 tb) and I want to check it, therefore I am trying to extract it to see if everything goes well. Since it is going to take a long time, I'd like to have some info printed on screen while extracting. Too bad the checkpoint actions suggested here don't work as intended. If try this command:

tar -xf big_fat_backup.tar --checkpoint=10000 --checkpoint-action=ttyout='%{%Y-%m-%d %H:%M:%S}t (%d sec): #%u, %T%*\r'

The meta characters in the string are not expanded (except for the %u), and I have the following output:

%{%Y-%m-%d %H:%M:%S}t (%d sec): #10000, %T%*

I simply copied from the manual, so what am I doing wrong?

Bonus question: If I create the archive with the -W switch and no errors are printed, should I be sure that the archive was written correctly?

  • You can also use -v to show progress: tar -xvf <file.tar> – drs Aug 5 '14 at 14:48
  • I don't want the verbose output on a couple of millions of files (which btw I don't know one by one, so the list is pretty useless), but rather I'd like to know how many MBs have been read, in order to have a generic idea of the process. – rookie coder Aug 5 '14 at 15:12
  • If you want to only test it, why not run tar -t? – Cristian Ciupitu Aug 6 '14 at 5:21
  • In the end that's what I did, redirecting the output to /dev/null and checking the exit code with 'echo $?'. – rookie coder Aug 6 '14 at 7:27
2

These meta characters for --checkpoint-action were introduced in version 1.28, which was released a week ago.

A way to get approximate progress status on demand is to check the position of the tar process in its input file. You can see that with lsof -p1234 where 1234 is the PID of the tar process. On Linux, you can check the pos: line of /proc/1234/fdinfo/3.

If you want a progress report on screen, you can filter the archive through pv.

<big_fat_backup.tar pv -bt | tar -xf -

If you want to be sure that the archive is written correctly, check the exit status of the tar command. This goes for any other command as well: an exit status of 0 means success, a nonzero value means a failure.

  • Thanks, if you look at my comment on the question, that's what I did. Very interesting to notice how quick the manual was updated, much faster than the actual code! I'd never had thought to check the version! Here's a well deserved +1! – rookie coder Aug 6 '14 at 7:29
  • @rookiecoder The manual wasn't updated faster than the code: it was updated on the website when the code was released. It takes time between the upstream release (when the product is out of the factory) and your installing the newer version (when your distribution (retailer) has the new version and you go and get the upgrade). – Gilles Aug 6 '14 at 7:47
  • Indeed if I type 'man tar' the local manual just says "--checkpoint-action=ACTION execute ACTION on each checkpoint", without listing the actions. Btw, where can I found the allowed actions with man? The word is underlined but that's all. – rookie coder Aug 6 '14 at 7:53
  • 1
    @rookiecoder GNU doesn't believe in man pages, they put their documentation in info format. Try info tar or another info browser (Emacs's built-in info browser is better than the standalone program). Some distributions package the documentation in HTML format as well. – Gilles Aug 6 '14 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.