Script:Resume a tar (and gzip)

I was compressing a huge text file into a tar.gz while doing about 10 other things this morning when my computer froze up. I desperately tried to get into the system monitor application and switching desktops (ctrl+alt+F5) with no luck. I had to actually use the power button 😦

7GB has already been written and I didn’t want to start over, so I just created this script to resume the creation of tar files.

#!/bin/bash

if [ $# -eq 0 ]; then
echo $0 [INFILES] [OUTFILE]
exit
fi
INFILES=$1
OUTFILE=$2
SIZE=”$(wc -c < $OUTFILE)”
tar -cvvz –to-stdout “$INFILES” | tail -c +$(($SIZE+1)) >> “$OUTFILE”

echo “${OUTFILE} creation completed!”

It seems to have worked just fine. I can’t see any errors in the file, but it was simply a large CSV. Give it a shot with different file types and report your successes and failures in the comments!

Leave a comment