Jump to content

Using rsync to sync mirror [solved]


Recommended Posts

I set up the three following jobs in /etc/cron.daily:

 

[admin@elan cron.daily]$ cat rsync_main
rsync -rv rsync://anorien.csc.warwick.ac.uk/Mandriva/official/2006.0/i586/media/main/* /home/ftp/pub/mirrors/
mandriva/official/2006.0/i586/media/main/

[admin@elan cron.daily]$ cat rsync_contrib
rsync -rv rsync://anorien.csc.warwick.ac.uk/Mandriva/official/2006.0/i586/media/contrib/* /home/ftp/pub/mirrors/
mandriva/official/2006.0/i586/media/contrib/

[admin@elan cron.daily]$ cat rsync_updates
rsync -rv rsync://anorien.csc.warwick.ac.uk/Mandriva/official/updates/2006.0/main_updates/* /home/ftp/pub/
mirrors/mandriva/official/updates/2006.0/main_updates/

 

I then made executable so that cron would run them using "chmod +x scriptname". I checked this morning, and found for some reason, that I was missing a few updates that had been released recently. This made me realise that the script wasn't working correctly, or cron didn't run the job for some reason.

 

Nothing seems to show in any logs for the rsync jobs, so it's making it a little difficult for me to tie down where the problem is. Am I running it the right way, or should I be using an alternative? I'm only mirroring for my own use, and not for people to connect and mirror from me since I don't have the bandwidth for this.

 

Any ideas appreciated.

Link to comment
Share on other sites

One of the updates was released a couple of days ago, but it only got picked up this morning when I ran the script manually.

 

So, I'm not sure it's running my job correctly for some reason, or even if I'm doing it the correct way anyhow. I know there is a rsync daemon, but I think this is to allow people to connect to you, rather than run schedule jobs.

 

I'll check in case it's a path problem, and add the full directory path to the script, but it certainly looks odd as to why it missed running the job and picking an update from two days ago.

 

EDIT:

 

scripts are the same as above except "/usr/bin/rsync -r" now, instead of what it read before.

Link to comment
Share on other sites

rsync by default could be run by any user, so path to rsync should not be a problem... did you not forgot to put the

 

#!/bin/sh

 

on your script.. I noticed the output of those you'd cat.. no #!/bin/sh.. or maybe you'v just exclude it :P

Edited by aioshin
Link to comment
Share on other sites

Yes, I didn't put it. Maybe that's it, I'll try now and see if it makes a difference! doh :o

 

I usually do put it, I must have forgotten it. I guess it's necessary after all. Will update, to see if it works over the next few days.

 

EDIT:

 

OK, now added to the beginning of the script:

 

#!/bin/bash

 

as I use bash normally, and I also noticed some scripts have bash and some have sh. Is it important which one is listed at the top, or not important as to which shell you use?

Link to comment
Share on other sites

  • 1 month later...

Ah ha, that could explain it then :P. I've never looked into it, but always set as /bin/bash anyhow. The script started working as soon as I added this. I guess they must need this identifier else they fail to run, which is cool. Means I learnt a bit about cron jobs and the lack of them running even though manual was fine :D

Link to comment
Share on other sites

you can also create a file under /etc/cron.d/ .. say /etc/cron.d/rsync_main then with the entries like below

01 20 * * * ian /usr/bin/rsync -rv rsync://anorien.csc.warwick.ac.uk/Mandriva/official/2006.0/i586/media/main/* /home/ftp/pub/mirrors/
mandriva/official/2006.0/i586/media/main/

 

so that would run 8:01 pm daily as been set and executed by user ian.. and that is only a plain file, you dont need to make that executable, but should be created by root.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...