LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rsync files that are 90 days old (https://www.linuxquestions.org/questions/linux-newbie-8/rsync-files-that-are-90-days-old-4175522097/)

dm7618 10-14-2014 10:39 AM

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

jlinkels 10-14-2014 12:31 PM

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

dm7618 10-14-2014 01:34 PM

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

Vafri 12-12-2014 10:55 AM

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.

Habitual 12-12-2014 12:25 PM

subscribed with interest...

Beryllos 12-13-2014 01:42 PM

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.

michaelk 12-13-2014 03:16 PM

--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.


All times are GMT -5. The time now is 08:48 AM.