Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-30-2013, 04:28 AM
|
#1
|
Member
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53
Rep:
|
rsync with daily changing file name
Hi,
Looking for a way to rsync a dir daily when the dir name changes daily by date, ie: dir name today is 2013_05_30 but tomorrow it will be updated and named 2013_05_31 by another script. So running rsync it will see the dir name is different and create a whole new dir with simular content, other than using a wild card like
#rsync -au 2013_* /destination is there another option?
Last edited by pixie; 05-30-2013 at 04:34 AM.
|
|
|
05-30-2013, 05:38 AM
|
#2
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,374
Rep: 
|
Something like this:
Code:
NameToday="`ls 2013*`"
mv $NameToday FixedName
rsync -au FixedName /destination
mv FixedName $NameToday
Provided that the other script doesn't change the name in parallel, of course 
Last edited by Didier Spaier; 05-30-2013 at 06:19 AM.
Reason: rsync command corrected.
|
|
|
05-30-2013, 05:51 AM
|
#3
|
Member
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53
Original Poster
Rep:
|
Thanks Didier Spaier !
That should work, though I just realised 2013* will need to be changed to 201* otherwise will have to rush home from bar on new years eve to alter script date 
|
|
|
06-02-2013, 01:03 AM
|
#4
|
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,992
|
Quote:
Originally Posted by Didier Spaier
Something like this:
Code:
NameToday="`ls 2013*`"
mv $NameToday FixedName
rsync -au FixedName /destination
mv FixedName $NameToday
Provided that the other script doesn't change the name in parallel, of course
|
Code:
NameToday="`ls 2013*`"
#mv $NameToday FixedName
rsync -auHXSv $NameToday /destination >> /path/to/logs/rsync.log
#mv FixedName $NameToday
the above change would work too. no need to move the file before you rsync it across your network. depending on how large the file is that could be very system heavy and could cause the system to become unresponsive for an extended time frame. not generally a good idea.
Last edited by lleb; 06-02-2013 at 01:05 AM.
|
|
|
06-02-2013, 03:13 AM
|
#5
|
Member
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53
Original Poster
Rep:
|
Quote:
Originally Posted by lleb
Code:
NameToday="`ls 2013*`"
#mv $NameToday FixedName
rsync -auHXSv $NameToday /destination >> /path/to/logs/rsync.log
#mv FixedName $NameToday
the above change would work too. no need to move the file before you rsync it across your network. depending on how large the file is that could be very system heavy and could cause the system to become unresponsive for an extended time frame. not generally a good idea.
|
Well its not a single file its hundreds of files. To explain, cpanel has a new backup script which now changes the dir name to a date name which changes every day/week the script is run. This backs up locally and then we rsync to remote backup server.
|
|
|
06-02-2013, 10:58 AM
|
#6
|
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,992
|
ok, still no need to rename the directory then, just use the variable in your rsync command and poof you are done.
|
|
|
06-02-2013, 11:18 AM
|
#7
|
Member
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53
Original Poster
Rep:
|
Quote:
Originally Posted by lleb
ok, still no need to rename the directory then, just use the variable in your rsync command and poof you are done.
|
Thanks very much 
|
|
|
All times are GMT -5. The time now is 07:00 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|