LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 10-14-2014, 10:39 AM   #1
dm7618
LQ Newbie
 
Registered: Oct 2014
Posts: 2

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


Hi
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, 12:31 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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.

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

Original Poster
Rep: Reputation: Disabled
Hi
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, 10:55 AM   #4
Vafri
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 12:32 PM.
 
Old 12-12-2014, 12:25 PM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

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

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
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, 03:16 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,743

Rep: Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923
--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.
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:32 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