LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-29-2004, 04:41 AM   #1
scialom
LQ Newbie
 
Registered: Jul 2003
Posts: 29

Rep: Reputation: 15
Ftp script


Hi,

I am running a daily script that backup my mysql db.
I want to upload my backup folder to my ftp server, everyday.

How can I do it?

Thanks,
Assaf
 
Old 04-29-2004, 06:08 AM   #2
Matt Collier
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 80

Rep: Reputation: 15
i'd use scp to transfer the file, there's a good article about passwordless ssh here

http://www.hackinglinuxexposed.com/a.../20030109.html

otherwise, this'll do it via ftp with perl:

#!/usr/bin/perl -w

my $username = 'user';
my $password = 'pass';
my $host = 'host';
my $file = 'file.tgz';

open(FTPHOST, "|ftp -n $host\n");
print FTPHOST "user $username $password\n";
print FTPHOST "bin\n";
print FTPHOST "prompt off\n";
print FTPHOST "put $file\n";
print FTPHOST "exit\n";
close(FTPHOST);
 
Old 05-04-2004, 03:03 PM   #3
Nnyan
LQ Newbie
 
Registered: Jun 2003
Posts: 6

Rep: Reputation: 0
This is what I'm currently doing in crobtab and it works fine for me. I had to install LFTP. If you have /usr/local/bin in your path then you can take out those two lines.

I'm a bit cautious by nature so take out the IF THEN statements. Also modify the mydate to whatever output you like.

I'm still trying to work out a way to disconnect users from the DB before I do a mysql dump b/c once I had a table that got locked "in use" and killed the backups (had to fix the table b4 I got it working again).

#! /bin/bash
mydate=$(date +%m%d%Y%l%M%p)
PATH=$PATH:/usr/local/bin
export PATH

/usr/local/mysql/bin/mysqldump --flush-logs --opt -u SQLUSER -pSQLPWD dbname > /dir1/dir2/dir3/backup.sql
cd /dir1/dir2/dir3/
if [ -e backup.sql ]
then
tar -czvf backup-$mydate.tar.gz backup.sql
fi
if [ -e backup-$mydate.tar.gz ]
then
lftp <<EOF
open FTPSERVER
user FTPUSER FTPPWD
pwd
put backup-$mydate.tar.gz
bye
EOF
fi
if [ -e backup-$mydate.tar.gz ]
then rm /dir1/dir2/dir3/backup.sql
fi
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 06:57 PM
where i could get freespace script for my FTP RINO2004 Linux - Software 1 08-27-2004 07:04 AM
Problem with FTP Script bmeckle Linux - General 1 07-22-2004 02:28 PM
FTP script Veteq Programming 3 04-21-2004 12:32 PM
ftp script dlm4444 Linux - Networking 5 02-10-2004 11:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration