LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 05-30-2013, 04:28 AM   #1
pixie
Member
 
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53

Rep: Reputation: 27
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.
 
Old 05-30-2013, 05:38 AM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,374

Rep: Reputation: Disabled
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.
 
Old 05-30-2013, 05:51 AM   #3
pixie
Member
 
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53

Original Poster
Rep: Reputation: 27
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
 
Old 06-02-2013, 01:03 AM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,992

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by Didier Spaier View Post
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.
 
Old 06-02-2013, 03:13 AM   #5
pixie
Member
 
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53

Original Poster
Rep: Reputation: 27
Quote:
Originally Posted by lleb View Post
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.
 
Old 06-02-2013, 10:58 AM   #6
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,992

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
ok, still no need to rename the directory then, just use the variable in your rsync command and poof you are done.
 
Old 06-02-2013, 11:18 AM   #7
pixie
Member
 
Registered: Aug 2003
Distribution: Mageia, Centos, CloudLinux
Posts: 53

Original Poster
Rep: Reputation: 27
Quote:
Originally Posted by lleb View Post
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
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rsync with changing directory structure dormant Linux - Software 6 08-28-2010 03:32 PM
Changing permissions of destination directory after rsync cliff123 Linux - General 1 12-26-2007 03:09 AM
Downloading daily file updates to server mike34341 Linux - General 5 07-07-2007 08:36 AM
Rsync changing owner of dirs Harlin Linux - Security 1 03-30-2007 01:11 PM
Daily Cron jobs with a PHP file Gargomel7 Programming 7 09-13-2003 07:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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