Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to use pv (pipeviewer) along with tar to do tape backups in order to see the progress and eta like so:

du -s /home/myuser
115630916   /home/myuser
tar -cf - /home/myuser/ | pv -s 115630916 > /dev/nst0

Which works fine, it writes to tape successfully. But once I try and test the tar archive:

mt -f /dev/nst0 rewind
tar -tvf /dev/nst0

I get the following errors:

tar: /dev/nst0: Cannot read: Cannot allocate memory
tar: At beginning of tape, quitting now
tar: Error is not recoverable: exiting

I've googled around and there have been suggestions that I use --blocking-factor=128 when creating my backup and restoring. I still get the same error.

It's also worth noting that if I just use tar, everything works 100%, including the restore, so perhaps pv is breaking it?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Solved it, pv was creating a different block / buffer size ...

From the pv man page:

The default buffer size is the block size of the input file’s filesystem multiplied by 32 (512kb max), or 400kb if the block size cannot be determined.

From the tar man page:

block size of Nx512 bytes (default N=20)

So give the correct buffer size to pv as (20 x 512 = 10240)

tar -cf - /home/myuser/ | pv -B 10240 -s 142524k > /dev/nst0

Now if you test the archive with tar -tvf /dev/nst0, it should work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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