Tar transfer and delete files

  • Follow


Hi,
I=B4m having a problem here. I have a directory that holds many subdirs
and files (by many I mean MANY thousands).
What I want to do is make blocks of these files and transfer them block
by block to a remote host; but once a given file is already placed in
the remote host, the script must delete the source file. Block size can
be upto 2GB.
My brain is melt down already; can anybody give me a hand with this.

Thaks

Dago

0
Reply dago.mailbox (1) 3/1/2006 12:31:35 PM

> What I want to do is make blocks of these files and transfer them block by
> block to a remote host; but once a given file is already placed in the remote
> host, the script must delete the source file. Block size can be upto 2GB.

One option could be to use tar(1) or gtar(1) and create a big file, then use
cut(1) to divide this into chunks. Since cut can automaticly name the parts its
creating you should then be able to use a simple script to copy these over.

Something in the likes of..

for a in `seq -w 1 50`; do scp filename$a <host> && rm filename$a; done

-- 
Groetjes, Peter

..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
0
Reply Lion 3/1/2006 2:58:24 PM


Thanks, Peter I'll try it out.

0
Reply Dago 3/1/2006 7:22:37 PM

"but once a given file is already placed in
the remote host, the script must delete the source file."

Given that requirement, rsync is the way to go. It won't do blocks
(unless you restrict the number of dirs / files per transfer) but it
will delete the source files as they are copied.

You can get rsync from SunFreeware.com. It also requires popt be
installed (same source).

Ron Halstead

0
Reply Ron 3/2/2006 8:46:18 PM

> Thanks, Peter I'll try it out.

Hold the presses!  I made a terrible goofup :-/

>> for a in `seq -w 1 50`; do scp filename$a <host> && rm filename$a; done

As you may, or may not, know I'm using Linux on my workstation and Solaris on
all my servers. The downside to this approach is that I sometimes mix between
the two, and this is another classic example since Solaris doesn't have the
'seq' command.

seq is a Linux program which basicly does what it says; it creates a sequence.
In my example it would have printed "01 02 03 ... 10 11 12 ...". So you
probably need to skip that and merely use *. Something like:

(in the directory with all your cut' files):

$ for a in *; do scp $a <host> && rm $a; done


That is bound to work on Solaris as well.  Sorry if I caused any confusion
here.

-- 
Groetjes, Peter

..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
0
Reply Lion 3/3/2006 8:51:18 PM

If you want to get a reliable sequence numbering, use this filter:

for a in `echo 1 50 |awk '{ for( i=$1; i<=$2; i++) {
printf("%02d",i)}'`
do
.....

This is platform agnostic.

-Dexthor.

0
Reply Dexthor 3/3/2006 8:56:09 PM

5 Replies
604 Views

(page loaded in 0.097 seconds)

Similiar Articles:













7/22/2012 7:28:30 PM


Reply: