Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was doing a : tar -cvf and I had to killed it with ctrl-C. I know I should have done a Ctrl-Z and then bring back the task to foreground... but it's not the story.

Can I resume from the point I stopped the task ?

share|improve this question
    
Is there an incomplete tar file in the destination location? –  Karthik T Dec 6 '12 at 9:35
    
Yes there is an incomplete tar. –  mthpvg Dec 6 '12 at 10:05
add comment

3 Answers 3

up vote 2 down vote accepted

This method will recreate your tar archive, and append the finished part to the existing file. This can be useful if backing up over a network connection. You will likely result in a corrupt archive if any of the data in your INFILES has changed. Be sure to test your archive after completion.

Change INFILES and OUTFILE to the correct names on the following line.

INFILES="my folder"; OUTFILE="archive.tgz"; SIZE="$(wc -c < $OUTFILE)"; tar -cz --to-stdout "$INFILES" | tail -c +$(($SIZE+1)) >> "$OUTFILE"

Explanation:

SIZE="$(wc -c < $OUTFILE)" # Get the current size of the archive.

tar -cz --to-stdout "$INFILES" | # Begin creating archive and send output to tail command.

tail -c +$(($SIZE+1)) >> # Disregard the data before $SIZE+1, and resume the rest of the archive $OUTFILE.

share|improve this answer
add comment

The best solution would be to delete the tar file and restart the process prepended with nohup and appended with &. Alternatively, you could run tar -tfv and use that as an exclude for the new tar -cvf.

share|improve this answer
1  
tar -cvf will overwrite the existing file. Did you mean tar -rvf? Also, the last file that was written to the archive was likely incomplete. –  Gilles Dec 6 '12 at 23:04
    
So the idea is to make a list of the files which are already in the tarball, minus the last one which is probably incomplete. And then run a tar -rvf ? –  mthpvg Dec 7 '12 at 10:42
add comment

You can't; you just need to start over.

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.