LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-22-2013, 11:59 AM   #1
zimbot
Member
 
Registered: Nov 2005
Location: cincinnati , ohio . USA
Distribution: ubuntu , Opensuse , CentOS
Posts: 179

Rep: Reputation: 17
how to lftp mirror in a bash


Friends
I wish to have a script that will do a lftp mirror
that will sync up a local dir to the ftp dir

local dir is is an external drive on my dsktop
/media/facing_history_1/00
where facing_history_1 is the drive and 00 is a dir I wish for the files to go to

the remote dir is on the ftp server
172.16.100.101 ,
the user is editor
the password apple
and the dir that I wish to source from is : array1/f_t

Note: i can do it manually - but wish to have a script that i can cron.

here is the script I am currently trying
<code>
#!/bin/bash
#########_______ test of mirror
log=~/log/f_h_logfile.txt
batch=00
dest=/media/facing_history_1/$batch
cd $dest
echo start $(date) >> $log

DATE='date +%Y%m%d'
#mkdir $DATE
echo "Get files"
#lftp -u username,password -e >> LOGFILE
#lftp 172.16.100.101 -u editor,apple cd array1/f_t mirror -c >> $log
lftp 172.16.100.101 -u editor,apple
cd array1/f_t
mirror -c
exit
echo end $(date) >> $log
echo ............ >> $log
</code>

currently when I run this script
i DO get to the ftp server
but it 'stalls' at root - meaning the cd array1/f_t never happens
nor does the mirror -c happen

when i run it I am logged into the server
and in that shell i can do a dir and see where i am and I can manually put in : cd array1/f_t , and that gets me there
and I can manually put in mirror -c , and that pulls the files.

so __ how do i put this all on 1 line and have it all happen
as you can see i did try - all 1 line -
lftp 172.16.100.101 -u editor,apple cd array1/f_t mirror -c

and I have tried in 3 lines
lftp 172.16.100.101 -u editor,apple
cd array1/f_t
mirror -c
but it stalls after the logIn

thanks
z
 
Old 01-22-2013, 01:09 PM   #2
zimbot
Member
 
Registered: Nov 2005
Location: cincinnati , ohio . USA
Distribution: ubuntu , Opensuse , CentOS
Posts: 179

Original Poster
Rep: Reputation: 17
ok I have something that is sorta working
<code>
#!/bin/bash
#########_______ test of mirror
log=~/log/f_h_logfile.txt
batch=00
dest=/media/facing_history_1/$batch
cd $dest
echo start $(date) >> $log

DATE='date +%Y%m%d'
#mkdir $DATE
echo "Get files"
#lftp -u username,password -e >> LOGFILE
#lftp 172.16.100.101 -u editor,apple cd array1/f_t mirror -c >> $log
#lftp 172.16.100.101 -u editor,apple
#set 'cd array1/f_t'
# mirror -c
###lftp -c 'open -e "set ftp:list-options -a; mirror -a --parallel=10 -v fromdir/ ./todir" -u user,pass host'
lftp -c 'open -e "set ftp:list-options -a; mirror -a -v array1/f_t/ ./media/facing_history_1/00" -u editor,apple 172.16.100.101 >> $log'
exit
echo end $(date) >> $log
echo ............ >> $log
</code>

but it does not log
lftp -c 'open -e "set ftp:list-options -a; mirror -a -v array1/f_t/ ./media/facing_history_1/00" -u editor,apple 172.16.100.101 >> $log'
isn the same as
lftp -c 'open -e "set ftp:list-options -a; mirror -a -v array1/f_t/ ./media/facing_history_1/00" -u editor,apple 172.16.100.101'

and it does not go to
echo end $(date) >> $log
echo ............ >> $log

i suppose that is the exit
but I was thinking the exit -- there-- would exit the ftp
and --sorta-- drop back into bash space

how might one do that
I am also trying to have a better understanding of what happens w the
lftp -c 'open -e "set ftp:list-options -a; mirror -a -v

any wisdom would be appreciated
 
  


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
lftp mirror function, ruined user:group on remote, cant delete files MJkrakowski Linux - Software 0 12-12-2012 10:44 PM
lftp mirror: Access failed: 550 /var/www/vhosts/test: No such file or directory speedy6 Linux - Software 11 10-22-2012 02:06 PM
lftp mirror problem ycxbiao Linux - Software 1 09-27-2009 09:42 PM
lftp mirror problem crusher88 Linux - Software 2 08-14-2009 01:03 AM
filezilla setting and lftp:mirror help samengr Linux - General 0 01-25-2008 05:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:08 PM.

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