LinuxQuestions.org
Visit Jeremy's Blog.
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 06-08-2010, 09:39 AM   #1
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Rep: Reputation: 48
rsync files with dates after a certain date


I was going to do a

rsync -r -a -z -v -p -e ssh

to move some files from one server to another, but then realized all I really need are files which have dates starting June 1, 2008 to current. Is there a way to have rsync only sync those files? The directory structure that's my source goes all the way back to 2004.
 
Old 06-08-2010, 10:04 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Assuming by "date" you mean "last modification date" (each file has 3 dates in Linux filesystems).

Perhaps you can use "find" to make you a list of files to rsync, then use --files-from option of rsync?

Code:
find /your/src/dir -mtime 3 > list_files_to_rsync;
rsync -azv -e ssh --files-from=list_files_to_rsync
Note: on my box, the rsync -a (archive) option includes -p (preserve permissions) and -r (recursive) among others.
 
Old 06-08-2010, 10:06 AM   #3
yooy
Senior Member
 
Registered: Dec 2009
Posts: 1,387

Rep: Reputation: 173Reputation: 173
have you tryied fetching those files and forward them with | command to rsync?

if that won't work, try copying them to seperate folder first.

note:havent't seen previous post when writing this

Last edited by yooy; 06-08-2010 at 10:09 AM. Reason: note:havent't seen previous post when writing this
 
Old 06-08-2010, 10:30 AM   #4
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
You could move/copy the files of interest to another directory and then rsync that directory only.

Say the current directory with all the files is called oldir and the directory where you want to move/copy the files to is called newdir .

If you execute:

Code:
$ find /home/myuser/oldir/* -mtime -60 -exec cp {} /home/myuser/newdir/ \;
This will copy all files modified in the last 60 days (-mtime) to newdir

You can change the value of mtime to suit your particular case.

Last edited by alli_yas; 06-08-2010 at 10:31 AM.
 
Old 06-08-2010, 04:53 PM   #5
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,697

Original Poster
Rep: Reputation: 48
I'd also like to preserve the folder hierarchy in the destination, will this preserve that?
 
Old 06-09-2010, 03:04 AM   #6
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Have a look at rsync's options. At first glance, adding -R should do the trick.
 
  


Reply


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 by date JeffElkins Linux - Server 4 01-30-2010 12:56 PM
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 file by newest date investmentbnker75 Programming 5 10-12-2008 11:44 PM
date increment not working on certain dates johnfman Programming 3 02-15-2008 12:38 PM
how to use rsync to update date/time only coontie Linux - Software 2 05-15-2006 12:13 PM

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

All times are GMT -5. The time now is 10:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration