Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 8304  / 3 Years ago, tue, september 14, 2021, 12:39:48

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?


More From » backup

 Answers
0

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.


[#40903] Wednesday, September 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ateact

Total Points: 176
Total Questions: 130
Total Answers: 122

Location: Egypt
Member since Sun, Apr 23, 2023
1 Year ago
;