LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-25-2011, 08:07 AM   #1
dman65
Member
 
Registered: Sep 2003
Posts: 61

Rep: Reputation: 15
Problem with tar, ssh, and a directory with 1.5 million entries


I have been attempting to use this command to copy files from one machine to another over ssh:

ssh root@192.168.1.69 "cd /data1/docimg && tar -c -N'10-22-2010'" | tar -xv

Running against this directory I receive an error after about 90 seconds:
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors

I then tried the command without the "| tar -xv" so I could see what was coming across. After a few seconds, it just returned with no kind of data being displayed at all.

I then ran the same original command but changed the directory from "docimg" to "reordered" which only has about 50 entries and this successfully copied all of the files based on the newer than restriction.

The "docimg" directory has about 1.5 million entries. I am wondering now if there is a maximum number of files in a directory for tar to work with. I have tried searching with +"tar" +"maximum files" and it seems to return every entry on the internet with a reference to a tar file and then some reference to "maximum files" and I didn't find anything useful. I know that the "cp" command as well as others have a limit on how many files they can process, but they usually return some sort of error, whereas tar is just not reporting anything.

If there is a file limit to using tar, is there some way to get around it or some other way to copy files that have been modified on or after a certain date from one server to another?

I have found the ssh and tar combination to be a lot faster than mounting samba or nfs and then using a find and copy combination.

Thanks for any insight.
 
Old 02-25-2011, 08:10 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
If I were you, I would use scp. Would make it easier, plus scp is made for transferring files via SSH.

EDIT: Sorry, didn't look at the full command. Working in this for you, give me a minute LOL

Last edited by corp769; 02-25-2011 at 08:16 AM.
 
Old 02-25-2011, 08:21 AM   #3
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Code:
ssh root@192.168.1.69 "for file in /data1/docimg/* ; do tar -c -N'10-22-2010' $file ; done" | tar -xv
Would something like this work?

It may need to be edited a bit to get it working, since I don't have your equivalent on my server...


Edit: My english.... my meds are trying to speak their mind....

Last edited by corp769; 02-25-2011 at 08:25 AM.
 
Old 02-25-2011, 08:32 AM   #4
dman65
Member
 
Registered: Sep 2003
Posts: 61

Original Poster
Rep: Reputation: 15
Thanks for the response corp769.

On my large directory I am getting nothing returned. On the directory with fewer entries I am getting:

tar: Cowardly refusing to create an empty archive

for each file in the directory.

I am guessing I may have to try and use the find command and see if that will work.
 
Old 02-25-2011, 08:35 AM   #5
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
I would like to test it on my server, but I have nothing to test with it. As far as your problem, I suggested the for loop to try to do it file by file. It would be your best bet.... Either a for loop, or find like you said, even ls and grep...
 
Old 02-25-2011, 08:44 AM   #6
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
AFAICS you are not specifying what to tar:
Code:
ssh root@192.168.1.69 tar -C /data1 -c -N10-22-2010 docimg | tar -xv
 
Old 02-25-2011, 10:10 AM   #7
dman65
Member
 
Registered: Sep 2003
Posts: 61

Original Poster
Rep: Reputation: 15
Sorry,

ssh root@192.168.1.69 "cd /data1/docimg && tar -c -N'10-22-2010' *" | tar -xv

Looks like I left out the asterisk when I was typing in the original message.
 
Old 02-25-2011, 10:12 AM   #8
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by dman65 View Post
Sorry,

ssh root@192.168.1.69 "cd /data1/docimg && tar -c -N'10-22-2010' *" | tar -xv

Looks like I left out the asterisk when I was typing in the original message.
Is that working then?
 
Old 02-25-2011, 10:17 AM   #9
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Well, the length of the command line is limited. This applies to other commands too in case you use * which is expanded by the shell. In your case I would suggest to use a dot instead of an asterisk.
Code:
ssh root@192.168.1.69 tar -C /data1/docimg -c -N10-22-2010 . | tar -xv
 
Old 02-25-2011, 12:36 PM   #10
dman65
Member
 
Registered: Sep 2003
Posts: 61

Original Poster
Rep: Reputation: 15
The * was in the command I was originally entering, so it does not work.

I tried with the "." about an hour ago. So far it hasn't copied anything, but it also hasn't returned an error, so it may just be looking through all of the files to find ones that match the criteria. I am not certain how long that should take on a list like that.
 
Old 02-25-2011, 12:37 PM   #11
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Can you check on the target system what's running there - it should show some impact in top.
 
Old 02-25-2011, 12:58 PM   #12
dman65
Member
 
Registered: Sep 2003
Posts: 61

Original Poster
Rep: Reputation: 15
tar is showing up in top, though it is only showing 9.44 seconds of processor time since being started about 90 minutes ago. Its priority is 18 so it has a lot of smbd activity ahead of it.
 
Old 02-25-2011, 01:04 PM   #13
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
If you are curious and as you have root access on the target machine, you can attach:
Code:
$ strace -p <pid>
to the tar process and should see it walking through the directories. I expect it should work this way.

Last edited by Reuti; 02-25-2011 at 01:04 PM. Reason: Typo
 
Old 03-02-2011, 02:04 AM   #14
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
I think tar is a pretty inefficient way to do what you are wanting

cpio is a better choice to stream the data over the network and then pipe it into tar on the local machine.

been a while and untested:

ssh user@remotemachine 'find /path | cpio -oaV' | tar czv blah.tar.gz

you can do all the time restrictions with find

Last edited by trey85stang; 03-02-2011 at 02:07 AM.
 
Old 03-02-2011, 04:20 AM   #15
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
You can save the output of the command cpio locally with a simple cat with a similar result, but cpio's format is a) different from tar ones, and b) your tar would archive blah.tar.gz to stdout while ignoring the stdin.

Sorry for being blunt.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
multimap with > 1 million entries = problems? true_atlantis Programming 14 09-11-2008 11:23 PM
LXer: Wikimedia to Sloan: Thanks a million, thanks a million, thanks a million LXer Syndicated Linux News 0 03-26-2008 02:50 PM
problem with tar over ssh Guttorm Debian 14 01-22-2007 01:00 PM
tar | ssh (tar > .tar) syntax issues EarlMosier Linux - Software 6 12-21-2006 12:28 AM
tar problem with backed up home directory dkaplowitz Linux - General 1 08-02-2003 04:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration