LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-06-2012, 01:23 AM   #1
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: Centos 5
Posts: 43

Rep: Reputation: Disabled
tar won't extract my archive properly?


Hi all,

i am simply trying to copy about 6Gb files/directories from an EXT3 USB drive, onto an EXT4 NAS. Because I am copying dovecot mail directories, it is important that the permissions are retained.

After lots of trial and error, I managed to use tar to create a complete permissions-inclusive archive without any errors:

tar -cvf /myarchive.tar -C / ext3USBmount

but now when I attempt to extract the archive with:

tar -xpvkf /myarchive.tar

I am getting lots of errors that read:

Cannot change ownership to uid <original uid>, gid 0: No such file or directory

an example of the full error with a filename might be:
home/j.bloggs/mail/.INBOX.subfoldername/cur/12345678.M64612314134.mydomain.com.au,S=1241,W=1285\:2,ST: Cannot change ownership to uid 576, gid 0: No such file or directory


Some other simple info:
- nothing's changed from source to destination, in terms of system setup/users/groups
- yes i'm logged in as root
- obviously i've stopped my mail processes before this tar command was exected, i would like to start my mail server again soon if at all possible

Thanks again,

Scott

Last edited by scottmusician; 04-06-2012 at 01:24 AM.
 
Old 04-06-2012, 01:30 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,627

Rep: Reputation: Disabled
I am not sure about /C option in the tar command. It should have been simple as
Quote:
tar cvfp /myarchive.tar <folder-name>

Last edited by linuxlover.chaitanya; 04-06-2012 at 01:35 AM.
 
Old 04-06-2012, 01:56 AM   #3
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: Centos 5
Posts: 43

Original Poster
Rep: Reputation: Disabled
thanks, i am trying that now ad it is recreating the archive as we speak.

Just to be clear, what would the extract command be? my guess is
tar -xvfp /myarchive.tar -C /

Last edited by scottmusician; 04-06-2012 at 02:03 AM.
 
Old 04-06-2012, 02:20 AM   #4
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: Centos 5
Posts: 43

Original Poster
Rep: Reputation: Disabled
hi again,

this is still not happy. Using:
tar cvfp /myarchive.tar <folder-name>
tar -xvpf /myarchive.tar -C /

is still giving me:
Cannot change ownership to uid <original uid>, gid 0: No such file or directory

funny how some files are OK but others generate this error. At first glance, it seems to be files with "." in their name (like, the contents of "/.INBOX". Which makes me think I haven't done something properly with permissions.

As an aside, does
chgrp -R 0 <foldername>
change group permissions of hidden files? I ran this command on my source folder before copying... (because i was trying to use cp instead of tar, and had even more permissions-related errors).
 
Old 04-06-2012, 02:21 AM   #5
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Rep: Reputation: 219Reputation: 219Reputation: 219
Quote:
Originally Posted by scottmusician View Post
Hi all,

i am simply trying to copy about 6Gb files/directories from an EXT3 USB drive, onto an EXT4 NAS. Because I am copying dovecot mail directories, it is important that the permissions are retained.

After lots of trial and error, I managed to use tar to create a complete permissions-inclusive archive without any errors:

tar -cvf /myarchive.tar -C / ext3USBmount
You have mentioned that you are planning to preserve permission while trying to tar but the command but I don't see any switch here

should have been something like this

Code:
#tar -cpvf /myarchive.tar -C / ext3USBmount

p == preserve permissions
c == create archive
v == verbose (print names while making tar)
z == gzip
f == tar file name
C == directory=DIR
are you sure you have compressed your directory properly?
 
Old 04-06-2012, 03:01 AM   #6
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: Centos 5
Posts: 43

Original Poster
Rep: Reputation: Disabled
I just confirmed with another attempt:
#tar -cpvf /myarchive.tar -C / ext3USBmount
#tar -xpvf /myarchive.tar -C /

also isn't working. Upon closer inspection of the verbose output, each file has two relevant lines: it looks like the file extracts OK, but the permissions aren't being set on it. eg:

home/user/mail/.INBOX.subfolder/cur/12345678.mydomain.com.au,S=788,W=811:2,ST
home/user/mail/.INBOX.subfolder/cur/12345678.mydomain.com.au,S=788,W=811\:2,ST: Cannot change ownership to uid 576, gid =: No such file or directory.

The difference between these two seems to be an inserted "\" character at the end of the W= ....
 
Old 04-06-2012, 04:49 AM   #7
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Rep: Reputation: 219Reputation: 219Reputation: 219
Quote:
Originally Posted by scottmusician View Post
Cannot change ownership to uid 576, gid =: No such file or directory.
I think the files are copied properly but the uid and gid they are trying to locate are not available on your machine
 
Old 04-07-2012, 02:54 AM   #8
scottmusician
Member
 
Registered: Jul 2011
Location: Melbourne, AU
Distribution: Centos 5
Posts: 43

Original Poster
Rep: Reputation: Disabled
I spent another few hours today trying to facilitate this copy, but so far still can't get the directory to replicate properly.

I gave up on tar because in spite of a couple more repeated tar attempts, the extracting of my tar archive was not only riddled with the above errors, but the extraction was also slowing gradually to a halt after only extracting about 25% of stuff.

So I've moved onto rsync:

rsync -avzH /source/ /destination/

but this also isn't working. The rsync seems to start confidently enough, copying files and folders without error... but after a while the rync routine doesn't end, it just stops with a flashing cursor for seeming eternity. (I left it sit for 2 hours today and it's certainly a 'crash' scenario, it's not processing anything and there's no hdd or network lights during this time.. nothing).

I hit Ctrl+C to quit, and upon further investigation, it looked like rsync created the directory structure oK, but only seemed to copy about 4Gb of my desired ~7Gb worth of data. Again, all the directories are there, and some of them are full.. but the others are empty. I've tried a few times and keep getting the same result.

Is there a simple gnome rsync front end or something that I could try? something similar to Carbon Copy Cloner for REHL would be nice? I thought about sharing both folders via smb and doing the copy on a host machine, but it seems ridiculous especially considering that I will need to script and automate this copy regularly using cron.

Any more ideas? I never thought such a simple, small copy could take more than 6 hours to troubleshoot...
 
Old 04-07-2012, 03:34 AM   #9
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
To extract the files and retain ownership, you need to extract the files as root (if you aren't the owner). If the destination share was exported with root squash, chown won't work. You also can't use "cp -a" and retain ownership either.

You can transfer large backups by piping the tar archive.
tar -C /path/to/basedir -cf - . | tar -C /path/to/destdir -xvkf -

If the destination is another host, you can do the same through an ssh tunnel, however ssh root access isn't the best idea.
 
  


Reply

Tags
dovecot, ext4, nas, permissions, tar


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Extract from `tar` archive as ordered in --files-from zx_ Linux - Newbie 6 02-04-2012 09:08 AM
[SOLVED] Extract each file from TAR archive separately zx_ Linux - Newbie 7 01-29-2012 04:53 PM
[SOLVED] tar fails to extract archive containing special characters shadowbox12 Linux - General 2 09-14-2011 06:05 AM
How to extract too large archive (35 GB) .tar file Bharat Kumar pankaj Linux - Server 10 08-19-2008 07:35 AM
tar won't extract a big archive & won't explain... wghay Linux - Software 4 03-05-2006 11:23 AM


All times are GMT -5. The time now is 06:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration