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 :D Rakso |
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 '{}' \; using find you can easily find directories created on a certain date and then you just run "cp -a" using the above option. -mark |
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 :) |
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 |
All times are GMT -5. The time now is 08:14 PM. |