Results 1 to 3 of 3

Thread: Rsync only files under 3 days old.

  1. #1
    Join Date
    Jul 2009
    Location
    Sheffield, England
    Beans
    73
    Distro
    Ubuntu 11.04 Natty Narwhal

    Rsync only files under 3 days old.

    Hi there.

    I have an Rsync set up between two images and the data in the source location goes back 45 days. I'm wanting rsync to only fetch the data that is less than 5 days old. Is this possible? I have the Rsync manual but can's seem to find anything.

    Would it be possible to use find over ssh and append rsync to whatever that outputs?

  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Rsync only files under 3 days old.

    Code:
    $ cd source
    $ find . -mtime +3 -type f -print0 | rsync -0v --files-from=- ~/source ~/destination
    find:
    -mtime +3 will match files 3 days old, and older.
    -type f will find only files.
    -print0 will print results with a null at the end, safer in case of strange characters in the filenames.

    rsync:
    -0 uses null as a separation.
    -v verbose, to see what's going on.
    --files-from=- receive file list from the standard input.

    Note: since the list of files has to be relative to the source directory, I 'cd' to the source directory first. As a side effect you'll need to use absolute paths as a source and destination (remember that ~ will expand to /home/youruser).

    I hope it helps,
    Regards.
    Last edited by papibe; September 3rd, 2011 at 07:52 PM. Reason: spelling, change +45 for +3

  3. #3
    Join Date
    Jul 2009
    Location
    Sheffield, England
    Beans
    73
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Rsync only files under 3 days old.

    That looks pretty bang on, thanks.

    I was thinking over the weekend of a better way to do it and originally I was rsynching from destination wheras I did have the brain wave that rsynching from source would do the job. You have verified that for me.

    Many thanks.
    Last edited by MrWestwood; September 5th, 2011 at 11:22 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •