1

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?

2 Answers 2

3

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.

0

I had a very similar error, but I wasn't using pv or anything else in a pipe between tar and the tape device.

The blocking factor bit is the key, though. I'd read that for best results, you should use a larger block size than the default, so i had used blocking factor 512 on the tar command line:

tar -b 512 -cf /dev/tape files

Unfortunately, tar doesn't automatically figure out the blocking factor, and you need to specify it on the restore too.

tar -b 512 -xpf /dev/tape

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .