lftp to sync folders but do not keep files older than 30 days old on synced machine.

here is what I did:

lftp ftp://ftp.server.com <<- DOWNLOAD
    user user@ftp.com "password"
    set ssl:verify-certificate no
    mirror -cn / /localfolder;
    bye
DOWNLOAD

this script works perfect to get the root folder on the ftp and sync with local folder, but here is what I want to accomplish now. I want to keep in my local folder only files that are newer than 30 days old base on the creation date of the file. So here is the example. lets say we run the script, the script will go to the ftp and download only the files that are newer than 30 days old and we do not have it inside the local folder and we will delete files older than 30 days on local folder. How can I accomplish this?
LVL 1
rafaelrglAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
You can use the mirror command with the option "-N now-30days"   (without ") or --newer-than=now-30days     added.

For local deletes try:
find /localfolder -type f -mtime +30 -print0 | xargs -0 rm -f

find will make a list of files (not directories) older than 30 days and print the list to xargs which will call rm on all the files in batches.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rafaelrglAuthor Commented:
perfect. works like its suppose to. thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.