LinuxQuestions.org
Review your favorite Linux distribution.
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
 
LinkBack Search this Thread
Old 03-16-2004, 03:59 PM   #1
mtn356
LQ Newbie
 
Registered: Sep 2003
Posts: 13

Rep: Reputation: 0
How to Shell Script auto ftp connection?


Hi,

Currently I backup our mysql databases from are Red Hat ES 2.1 maintained by a web hosting provider manually. This means I run mysqldump and download the file each day. I would like to shell script the process if possible. I have the mysqldump portion complete now I just need to connect up to our local ftp server and drop the data. I cannot seem to get past the username and password part. Has anybody done anything like this that can help me. Or maybe just a better approach than ftp all together? We have a dedicated soulution so I have full access to the box to run what I need.

Thank You,

Mike.
 
Old 03-16-2004, 04:27 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,950
Blog Entries: 11

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
You may consider setting the machines up
so they allow passwordless ssh connections,
and then just scp stuff back and forth.


Cheers,
Tink
 
Old 03-16-2004, 05:31 PM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
Box1 = Backup box with mysql database
Box2 = Remote ftp

On box1 create a .netrc file with entrie like this and save it in your home directory.

machine ftp.box2.com login yourlogin password yourpassword

NOTE: yourlogin must be a valid login on Box2 and needs write privledges to the save to the directory directory.

Now create a script like this. NOTE you may need to tweek this script a little for your situation.

#!/bin/bash
cd /path/to/mysqldumpfile
lftp <<EOF
open ftp.box2.com
cd /path/to/mysqlsavefile
pwd
ls
put mysqldumpfile
bye
EOF

You can edit crontab and have the script run at a preset time each day.

I don't know what all versions of ftp this will work with but I use similar scripts with lftp and they work.

<edit>CAUTION!!! Make sure .netrc file is chmod 600. Very important for security reasons.

Last edited by /bin/bash; 03-16-2004 at 05:35 PM.
 
Old 03-18-2004, 07:59 AM   #4
mtn356
LQ Newbie
 
Registered: Sep 2003
Posts: 13

Original Poster
Rep: Reputation: 0
worked great.


Thank you.
 
Old 03-18-2004, 07:31 PM   #5
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
You're welcome.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
auto execute shell script on startup slackwbas Slackware 9 02-27-2005 10:26 AM
Auto-Executing Shell Script on boot benrose111488 Linux - Software 5 12-18-2004 12:52 AM
auto execute shell script ykirankumar Linux - Software 3 09-22-2004 07:23 AM
Connection, login and upload files to ftp server via shell script Paulo Ges Linux - Networking 2 02-21-2004 01:01 PM


All times are GMT -5. The time now is 07:38 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration