Operating System - HP-UX
1832541 Members
6659 Online
110043 Solutions
New Discussion

tar-compres directorys and send

 
Goran Bulut_1
Advisor

tar-compres directorys and send

Hi all

Could anyone tall me how to do script or !!!!!!!! to do:

Tar all directories from 1000 to 3000 and to transfer them to computer name/folder

Thank you in advance

Goran
7 REPLIES 7
harry d brown jr
Honored Contributor

Re: tar-compres directorys and send


Why not just copy them to another place??

rcp -rp directory host:destination_directory


If you are asking how to tar directories name 1000 through 3000 then do this:

tar -cvf /dev/dmt/0m [1-2][0-9][0-9][0-9] 3000

live free or die
harry
Live Free or Die
Patrick Chim
Trusted Contributor

Re: tar-compres directorys and send

Hi,

You can type

tar cf - 1??? 2??? 3000 | remsh "cd && tar xf -"

Beware that the user executing this command has the remsh right on remote host

You can 'man tar' for more details.
Hope this help !!

Regards,
Patrick
Allan Pincus
Frequent Advisor

Re: tar-compres directorys and send

Goran,

Assuming you have directories such as 1001, 1399, 2100, 2850, etc (i.e. not just directories 1000, 2000, and 3000), the following script should work:

tar cvf myTar.tar [1-3][0-9][0-9][0-9]
ftp -v -n hostname_or_IP_addr < /tmp/ftp.log
user user_name password
bin
cd directory_you_want
put myTar.tar
bye
!

This script will tar up all your directories numbered anywhere from 1000-3000 (inclusive), then ftp to a remote machine, send the file across and go away.

A file called "/tmp/ftp.log" will be created (you must use the -v flag) which you can look at to make sure the ftp was successful.

Good luck!

- Allan
Sean OB_1
Honored Contributor

Re: tar-compres directorys and send

Allen,

Wouldn't this grab everything from 1000-3999 instead of 1000-3000?
Allan Pincus
Frequent Advisor

Re: tar-compres directorys and send

Sean,

You are right! Good catch. I guess you need to put:

tar cv [1-2][0-9][0-9][0-9] 3000

- Allan
harry d brown jr
Honored Contributor

Re: tar-compres directorys and send


That;s why I posted :

tar -cvf /dev/dmt/0m [1-2][0-9][0-9][0-9] 3000



1000-2999 + 3000

:-))


live free or die
harry
Live Free or Die
Jordan Bean
Honored Contributor

Re: tar-compres directorys and send


This should work for the initial copy:

cd /path/to/folders
find [1-2][0-9][0-9]0-9] 3000 -xdev | cpio -o | remsh rhost 'cpio -idmux /path/to/folders'

Then for daily incrementals, you can do this:

cd /path/to/folders
find [1-2][0-9][0-9][0-9] 3000 -type f -mtime -1 -xdev | cpio -o | remsh rhost 'cpio -idmux /path/to/folders'