LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-28-2007, 12:23 PM   #1
DjRakso
LQ Newbie
 
Registered: Nov 2006
Posts: 12

Rep: Reputation: 0
Find & Transfer to FTP Script


Hi,
I have a program that creates backups of certain files everything into a directory everyday.

My problem is that I would like to make a script to find out the most recent directory created on that same day as the computer as (labelled as year_month_date, ie: 2007_02_28) and then copy that entire directory and its contains and label that as something and transfer to a local ftp server as a secondary backup. This script will be executed every 10am via crontab.

Hopefully this is a newbie questions
Thx for reading my thread

Rakso

Last edited by DjRakso; 02-28-2007 at 12:24 PM.
 
Old 02-28-2007, 01:27 PM   #2
andrews-mark
Member
 
Registered: Feb 2007
Location: London
Distribution: debian
Posts: 108

Rep: Reputation: 15
sounds like a job for "find" with the "exec" option.

in case that is not familiar to you, here is an example i found online
at http://www.athabascau.ca/html/depts/...HOWTO/find.htm

Code:
    find . -name "rc.conf" -exec chmod o+r '{}' \;
"This command will search in the current directory and all sub directories. All files named rc.conf will be processed by the chmod -o+r command. The argument '{}' inserts each found file into the chmod command line. The \; argument indicates the exec command line has ended. "

using find you can easily find directories created on a certain date and then you just run "cp -a" using the above option.

-mark
 
Old 02-28-2007, 03:01 PM   #3
DjRakso
LQ Newbie
 
Registered: Nov 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Yup, I got the ftp mostly working....
Just is there a way to like pipe the output of the finds and then get the ftp prompt to copy those files onto the remote server?

BKUP_DIR=/backup/
cd $BKUP_DIR
find . -name "" -exec chmod o+r '{}' \;
cp -a
ftp -v -n 192.168.1.3 << EOF
user tester tester
binary
prompt
cd /backup/
mdel *.*
mput *.*
prompt
quit
EOF

See at the find line, I want to find the newest directory located in "backup" save that name of that folder (ex: 2007_02_20). The find will cehck to see if the folder as been within 7 days modified. When connected to the remote FTP, goes to the "backup" directory. Makes a directory named like "2007_02_20" and dumps anything from the local comptuer to the remote computer.
Thx

Last edited by DjRakso; 02-28-2007 at 03:03 PM.
 
Old 03-01-2007, 04:44 AM   #4
andrews-mark
Member
 
Registered: Feb 2007
Location: London
Distribution: debian
Posts: 108

Rep: Reputation: 15
Hi, Maybe I am misunderstanding you a bit (I am not quite sure what you are doing with the chmod in the find command). If ftping the files is the cause of your hassle, maybe if you have the option, try using scp. You can use keys and have this work passwordless. In that case, it would almost identical in syntax to using cp and could be pretty simple.

If you have to use ftp, however, I think everything still should be possible using the find exec combination.

-mark
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
FTP transfer freezes TheRudy Debian 3 01-15-2007 03:16 PM
shell script to transfer file from ftp bbgtilak Linux - General 1 12-27-2006 08:35 AM
Ftp freezes up during transfer GeneralChaos Slackware 2 10-04-2005 09:52 PM
Using BASH script to transfer a file via (s)ftp senther Linux - Newbie 2 07-19-2005 05:47 PM
Is there a script to auto find installed distros & edit Grub clintbrot Linux - Software 3 06-16-2005 11:15 PM


All times are GMT -5. The time now is 06:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration