Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-14-2014, 11:39 AM   #1
LQ Newbie
Registered: Oct 2014
Posts: 2

Rep: Reputation: Disabled
rsync files that are 90 days old

Can anyone help im stuck trying to get rsync to delete files on my destination location when using a find command to find files from the last 90 days

I am using find /source -mtime -90 to find the files i want then trying to try and get rsync to sync them but including deletions on the destination folder
I have tried many rsync command trying files-from switch |rsync and > rsync and -exec rsync {} etc.

Any help greatfully recived
Old 10-14-2014, 01:31 PM   #2
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,191

Rep: Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039
I don't fully understand what your need is.

Do you want to copy files to the destination which are older than 90 days?
Or do you want to delete files in the destination older that 90 days?

When you want to delete, are those files still on the source?
Do you want to keep them on the source?

What I think you want to do is this:
All files older than 90 days which are on destination must be deleted, regardless their existence on the source.
In that case I can recommend not to use rsync. Rsync is for syncing, but you want to do something else which is not syncing. Rsync is not good at that.
A better approach might be to run a remote find command on the destination deleting files older than 90 days. When you ssh into the destination you can append a command to ssh. In this case it would be a find command.

Old 10-14-2014, 02:34 PM   #3
LQ Newbie
Registered: Oct 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for replying, let me try and explain better.

I have a source location which will have files created, modified and deleted on. I want to sync the last 90 days of this location to another location. I can find changes and updates but not get rsync to delete on the location if a file is deleted on the source.

The reason for this work is to have the last 90 days of users data in sync in another location.

Thanks again
Old 12-12-2014, 11:55 AM   #4
LQ Newbie
Registered: Oct 2013
Posts: 2

Rep: Reputation: Disabled
I'm also looking into doing what he is describing. Did anyone find an solution for this? I have a source that I want to rsync to a destination but I want the files on the destination to stay around for 90 days after they have been removed from the source. Additionally I would accept an alternative solution which would accomplish the same goal.

Last edited by Vafri; 12-12-2014 at 01:32 PM.
Old 12-12-2014, 01:25 PM   #5
LQ Veteran
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
subscribed with interest...
Old 12-13-2014, 02:42 PM   #6
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 524

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
This could be done with a daily backup script which performs an incremental rsync backup by using the --link-dest option, and deletes any backups older than 90 days. You don't need the find command or the rsync --delete option.

I am not sure this is what you asked for or what you need, but I'll tell you what it will do for you: For each day in the desired 90-day history, you will be able to access the files as they existed at the time of the daily backup. The backups could be saved in date-coded directories, for example, a directory called 2014-12-13 for today's backup, a directory called 2014-12-12 for yesterday's backup, and so on. Since you used the rsync --link-dest option, files which did not change will be hardlinked, which saves disk space; the same file will not be stored twice, but it will appear in multiple daily backup directories because of the hardlinks.

If this sounds like what you need, let me know, and I could give you more details about how to write the script.
Old 12-13-2014, 04:16 PM   #7
Registered: Aug 2002
Posts: 19,422

Rep: Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103Reputation: 3103
--delete will delete the files in the destination not present in the source,

Why only sync the past 90 days? rsync only sends the delta difference.


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
rsync can not rsync files with include filter... xiutuo Linux - Server 2 07-23-2010 03:10 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 05:08 AM
rsync - sync files modified within the last 60 days boomklever Linux - Networking 3 06-03-2009 10:41 AM
Rsync only last X days tnine9 Linux - Software 9 05-18-2008 10:27 PM
rsync files accessed under 30 days 0ddba11 Linux - General 3 11-03-2005 07:59 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration