- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- FTP Script for Backups in Bourne Shell - Script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-14-2001 01:59 PM
тАО05-14-2001 01:59 PM
I need to have a script run from Server A to
Server B every night at 4am.
I wasn't sure if it was possible to script ftp commands on UNIX. I want to use a script to mounts Server A file system and then copies the data to Server B and then dismounts when done until all the files are copied over.
Server A is our production server and Server
B is our test server at another physical location.
The files look like this:
/db01/syb115/backup/*.gz
/db02/syb115/backup/*.gz
/db03/syb115/backup/*.gz
This would enable us to have live backups
at another site. I need a script and a cron
job update. You guys are great for helping me.. Thank You So Much...
TIA,
Laurie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-14-2001 02:17 PM
тАО05-14-2001 02:17 PM
SolutionHere are two scripts:
#!/usr/bin/sh
ftp -n << EOF
verbose
open thehost
user uuu ppp
get /tmp/stuff
close
EOF
...
#!/usr/bin/sh
{ echo "open thehost
user uuu ppp
hash
mput *
close"
} | ftp -i -n -v 2>&1 | tee /tmp/ftplog.$$
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-14-2001 02:23 PM
тАО05-14-2001 02:23 PM
Re: FTP Script for Backups in Bourne Shell - Script
If it were me I would avoid ftp simply because of the need for plaintext passwords unless you use anonymous ftp which defeats the whole purpose. I think I would do something like this using rcp:
FILES="/xxx/file1.gz /yyy/file2.gz"
REMOTE_HOME=elvis
for X in ${FILES}
do
rcp -p ${X} ${REMOTE_HOST}:${X}
done
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-14-2001 04:12 PM
тАО05-14-2001 04:12 PM
Re: FTP Script for Backups in Bourne Shell - Script
Two more points for questions I suspect you will ask as soon as you read the above posts:
1. Embedding a password in a script isn't the most desirable thing to do from a security perspective. A "better" approach may be to use a '.netrc' file ['man 4 netrc'] in which you can isolate the password (in one place).
2. In order to ascertain the success or failure of a scripted ftp, parse the messages logged from the session. I use the second script to capture the server/client dialog. Note that the '-v' [verbose] option is set and both stdout & stderr are redirected to a file. The messages from the session contain numbered text. From the 'ftpd (1m)' man pages you can note that "Every command produces at least one reply, although there may be more than one. A reply consists of a three-digit number, a space, some text...The number must conform to this standard, but the text can vary...The first digit of the message indicates whether the reply is good, bad, or incomplete." Thus, use the numbers associated with the text of the messages to discern the success or failure of the process.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2001 12:55 AM
тАО05-15-2001 12:55 AM
Re: FTP Script for Backups in Bourne Shell - Script
/etc/mount serverA:/db01 /backupsource
/usr/bin/cp -rp /backupsource/syb115/backup/*.gz /backupdir/db01
/etc/umount /backupsource
(same for db02 and db03)
Use full pathnames if you set this up as a script run by cron. Of course you can do this copies in a while- or for-loop.
Hope this helps. Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2001 01:23 AM
тАО05-15-2001 01:23 AM
Re: FTP Script for Backups in Bourne Shell - Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2001 07:16 AM
тАО05-15-2001 07:16 AM
Re: FTP Script for Backups in Bourne Shell - Script
When I try to do the rcp just in the shell
I get this error below..what does this mean?
I am excuting this as root and the file is
own by syb115 (sybase database) and group
is syb115 for the files.
remshd: Login incorrect.
I can do nslookup on the target host, we are
all on the same network.
Also what would be my cron entry to execute
this every day at 4am and send me email?
THANK YOU
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2001 07:27 AM
тАО05-15-2001 07:27 AM
Re: FTP Script for Backups in Bourne Shell - Script
No problem - this is normal. We have to tell machine A that machine B is trustworthy. You have permission problems.
I would do this on all machines that wish to execute the 'r' commands (rlogin,remsh,rcp,etc.):
1)Make sure there is an /etc/hosts.equiv file;
the format is:
machineA
machineB
machineC
(you can man hosts.equiv for more details and options). I would set the permissions to 644 and owned by root:root.
2) You also need to create a .rhosts file in the user's home directory (in this case root so I'll assume '/.rhosts'. I would do this on all the machines in question as well.
The format should be something like this:
machineA root
machineB root
machineC root
You can man .rhosts for details and other options for this file. I would also man remshd - you need to know the details of the remote executions and how they work.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2001 07:31 AM
тАО05-15-2001 07:31 AM
Re: FTP Script for Backups in Bourne Shell - Script
hosta root
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-15-2001 07:34 AM
тАО05-15-2001 07:34 AM
Re: FTP Script for Backups in Bourne Shell - Script
I forgot, set the permissions of the .rhosts
file to 600. Owner should be root:root.
If you like (and it's a bit more secure), you
can also set the hosts.equiv permissions to 600.
Again, I urge you to read the man pages on these files so that you understand the permissions implications.
Clay