1834445 Members
2868 Online
110067 Solutions
New Discussion

TAR problem

 
Mauro_8
Frequent Advisor

TAR problem

I used TAR to backup the current directory with "tar cvf backup.tar ./"
When I try to do a "tar xvf backup.tar" I received a error like: blocksize changed and stop the extract action.

I hope you can help me...
Cheers,
Mauro
15 REPLIES 15
harry d brown jr
Honored Contributor

Re: TAR problem

Mauro,

What do you get when you do this:

tar -tvf backup.tar


live free or die
harry
Live Free or Die
Mauro_8
Frequent Advisor

Re: TAR problem

Hi Harry,

I got a message like : "directory checksum error".
It??s really strange. Maybe I should define a blocksize when doing "tar cvf ...", ok ?

Cheers,
Mauro

Re: TAR problem

The problem is the tar file is in the directory you are backing up... so when you extract it, you overwrite the existing tar file with the backed up one, which was open and being written to when it was backed up.

Try tar cvf /tmp/backup.tar ./

and then tar xvf /tmp/backup.tar


That should work...

HTH

Duncan

I am an HPE Employee
Accept or Kudo
K.Vijayaragavan.
Respected Contributor

Re: TAR problem

Hi,

where is the backup.tar file located?

Keep it away from the directory for which you are taking backup and retry.

Ex.

tar -cvf /back/backup.tar /home

this backs /home directory into the file /backup.tar in the folder /back.

Seems to be path problem. Excuse me, if it is incorrect!

-Vijay
"Let us fine tune our knowledge together"
Steve Steel
Honored Contributor

Re: TAR problem

Hi

If you used a no rewind device that could cause problems since you are at the end of the archive.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Mauro_8
Frequent Advisor

Re: TAR problem

I did a backup with "tar cvf backup.tar ." then remove all the files from the current directory except backup.tar, then with only this file in the current directory I did "tar xvf backup.tar" and receive those messages, ok ?

Cheers,
Mauro
Steve Steel
Honored Contributor

Re: TAR problem

Hi


Also try the w option in the restore

Then it will ask before restoring a file.

Give n every time and it will step through the archive.

Remember fbackup is a better tool.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Luc Bussieres
Frequent Advisor

Re: TAR problem

Hi,

The other thing you could try is not to put the / after the dot. When I use tar I never put that ending /.

tar cvf backup.tar .

Luc
La réponse est le malheur de la question
K.Vijayaragavan.
Respected Contributor

Re: TAR problem

What happens if you create a new directory and try to extract it there?
Ex.
mkdir test
cd test
tar -xvf /path/backup.tar

Vijay
"Let us fine tune our knowledge together"
harry d brown jr
Honored Contributor

Re: TAR problem

Mauro,

THe problem is that your backup.tar file is also in the backup.tar file, and when it attemtped to restore it it clobbered the backup.tar file making it useless, I tested exactly what you did:

# ll
total 20360
-rw-r----- 1 root sys 1689600 Dec 24 10:19 cvs-1.10.8-sd-11.00.depot
-rw-r----- 1 root sys 8734720 Dec 24 10:19 cvs-1.10.8-ss-11.00.tar
drwxr-xr-x 2 root root 96 Aug 13 2001 lost+found
# tar -cvf backup.tar ./
a ./cvs-1.10.8-ss-11.00.tar 17060 blocks
a ./backup.tar 17060 blocks
./backup.tar: file changed size
a ./cvs-1.10.8-sd-11.00.depot 3300 blocks
# tar -xvf backup.tar
x ./cvs-1.10.8-ss-11.00.tar, 8734720 bytes, 17060 tape blocks
x ./backup.tar, 8734720 bytes, 17060 tape blocks
Tar: error! blocksize changed
# ll
total 20396
-rw-rw-rw- 1 root sys 18432 Feb 21 07:56 backup.tar
-rw-r----- 1 root sys 1689600 Dec 24 10:19 cvs-1.10.8-sd-11.00.depot
-rw-r----- 1 root sys 8734720 Dec 24 10:19 cvs-1.10.8-ss-11.00.tar
drwxr-xr-x 2 root root 96 Aug 13 2001 lost+found
# tar -tvf backup.tar
rwxr-xr-x 0/0 0 Feb 21 07:55 2002 ./
rwxr-xr-x 0/0 0 Aug 13 14:33 2001 ./lost+found/
rw-r----- 0/3 8734720 Dec 24 10:19 2001 ./cvs-1.10.8-ss-11.00.tar
Tar: error! blocksize changed
#

your backup.tar file is now toast (useless)

live free or die
harry


Live Free or Die
harry d brown jr
Honored Contributor

Re: TAR problem

Mauro,

I did the same backup one directory above:

# tar -cvf backup.tar ./appl
a ./appl/cvs-1.10.8-ss-11.00.tar 17060 blocks
a ./appl/cvs-1.10.8-sd-11.00.depot 3300 blocks

# ls -l backup.tar
-rw-rw-rw- 1 root sys 10434560 Feb 21 08:06 backup.tar
#

Notice how large backup.tar is? That's because I wasn't backing up the file backup.tar. And because the size of backup.tar was increasing in your example, it clobbered your backup.

live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: TAR problem

Mauro,

Hopefully you have another backup on tape somewhere. You will be able to extract only the files listed by doing a :

tar -tvf backup.tar


live free or die
harry
Live Free or Die
Darrell Allen
Honored Contributor

Re: TAR problem

Hi Mauro,

The problem is you are telling tar to archive the current directory structure and your tarfile output is being written to the same directory. The first thing your tar command does is to open backup.tar for writing. Then tar begins walking the directory structure, adding all files it finds in the directory to backup.tar. All is well until tar comes to backup.tar. It begins reading and writing to the same file. Basically you have corrupted backup.tar. You will never be able to create a good archive like this.

I believe you have two choices for workarounds:
1. Specify backup.tar in another directory:
tar cvf /another_dir/backup.tar

2. Specify all files in the current directory instead of the current directory:
tar cvf backup.tar *

backup.tar must not exist before you use choice number 2 or you will have the same problem. Simply do rm backup.tar before using choice number 2.

* will not archive hidden files so you may want to specify them as well:
tar cvf backup.tar * .file

Choice number 1 is a much more simple approach unless you don't have hidden files.

You may wonder why * doesn't include backup.tar.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Mauro_8
Frequent Advisor

Re: TAR problem

I solved my problem using the first option gived by Darrel Aren, it??s working fine.

Thanks all who helped me in this little doubt.

Regards,
Mauro
harry d brown jr
Honored Contributor