How to Shell Script auto ftp connection?
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.
You may consider setting the machines up
so they allow passwordless ssh connections,
and then just scp stuff back and forth.
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.
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.
|All times are GMT -5. The time now is 03:27 PM.|