1828584 Members
2605 Online
109982 Solutions
New Discussion

script help

 
SOLVED
Go to solution
Ragni Singh
Super Advisor

script help

Hi, I am trying to write a script that will do a tar of the / , then ssh to another host and write to the tape on the host. Unfortunately the script doesn't seem to work. Any assistance is greatly appreciated.

#!/bin/sh
list=`cat /root/list` (just has / in the file)
backuplog=/var/tmp/backup.log
date=`date`

tar -cvf "$list" | ssh hostname dd of=/dev/rmt/0m

#end of script

Here is the result that is produced:

tar: Cowardly refusing to create an empty archive
Try `tar --help' for more information.
0+0 records in
0+0 records out




10 REPLIES 10
Steven E. Protter
Exalted Contributor

Re: script help

ssh [-l login_name] hostname | user@hostname [command]

For this to work without password prompting, you will have needed to exchange public keys(attached)

From the man page.


The file $HOME/.ssh/authorized_keys lists the public keys that are permitted for logging in.


There are a ton of options on the manpage that might be relavent in making this process work.

Don't give up and use rexec...

P
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: script help

Right when I hit submit I had another idea.

create the tar file locally.

scp the file across(you will still need public keys)

then to the ssh command and only include the part you need to login and write the tape.

It makes the command line less complex and easier to debug

tar -cvf "$list"
scp tarfile remotlocation
ssh hostname dd of=/dev/rmt/0m

Just make the process on the other box something that writes the tar file straight to tape.

P
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
harry d brown jr
Honored Contributor

Re: script help

Why not just use gnu tar??

http://hpux.cs.utah.edu/hppd/hpux/Gnu/tar-1.13.25/

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

Re: script help

Actually, it looks like you are using gnu's tar, the "--help" gave it away. Why not use the "remote" option:

http://www.gnu.org/manual/tar/html_mono/tar.html#SEC123

live free or die
harry
Live Free or Die
Denver Osborn
Honored Contributor

Re: script help

Have tar write to stdout...

try this:

tar cvf - "$list" | ssh hostname dd of=/dev/rmt/0m

hope this helps
-denver
harry d brown jr
Honored Contributor

Re: script help

With gnu tar, it would be something like this:

/opt/tar/bin/tar -cv --file=hostname:/dev/rmt/0m "$list"

live free or die
harry
Live Free or Die
Ragni Singh
Super Advisor

Re: script help

Thanks for all the help all but how would I specify it if I am only taring up local and not any NFS mounted filesystems. In teh $list, I just have / which is what I want but not include any NFS mounted filesystems. Thanks for all the help and I will assign points once I have this up and running.
Jordan Bean
Honored Contributor

Re: script help

I'm not familiar with an option to restrict tar to a single filesystem...

How about pax?

pax -wXx ustar / | ssh user@host dd of=/dev/rmt/0m

Or cpio?

find / -xdev | cpio -o | ssh user@host dd of=/dev/rmt/0m

Huc_1
Honored Contributor
Solution

Re: script help

Try this

tar -cv / | ssh username@ip_address dd of=test.tar

or

tar -cv / | ssh username@ip_address dd of=/dev/rmt/0m

the above is interactive and will prompt you for a password unless you
have set up your ssh client to work without one

I would test this on a small directory and in a test environment before using
it in cron and in production environment.

ex:
tar -cv /test/blabla/ | ssh username@ip_address dd of=/whatever/test.tar


hope this helps
Jean-Pierre Huc
Smile I will feel the difference
Darrell Allen
Honored Contributor

Re: script help

Be sure to heed Denver's advice. The tar command you posted was specifying "$list" as the target for the tarfile to be created, not the source.

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