It is currently Mon Feb 27, 2017 12:43 am

running rsync script as non-root

All times are UTC - 6 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Dec 12, 2006 1:54 pm   

Joined: Tue Dec 12, 2006 1:42 pm
Posts: 2
Hi, got a rsync script that's nice. It seems to work fine until someone tries to upload a file to one of the directories it wants to synch. I was thinking of running/calling a setuid chown script before the rsync script to get around the ownership issue. Are there any other ways around this?

Here's the script:

#scriptname: stockfiles.rsync.bash
#scriptcreatedate: 20061120

#reference material
#date +%Y%m%d%H%m
#echo $testing | rev | cut -f1 -d/ | rev
#crontab entry:
#0,15,30,45 * * * * /home/rsync/stockfiles.rsync.bash >> /home/rsync/stockfiles.rsync.bash.log 2>&1
#find ~/*.$0.log -ctime +14 -type f -print | xargs /bin/rm -f

ScriptName=`echo $0 | rev | cut -f1 -d/ | rev`
LogFile=~/`date +%Y%m%d`.$ScriptName.log

Command='rsync -avze ssh --delete'

date > $TempLogFile

for i in northernweb1 northernweb2; do (
   for j in html images text logos; do (
      echo gonna do this: $Command $Directory/$j $i:$Directory
      $Command $Directory/$j $i:$Directory ; sleep 5
   ); done
); done

date >> $TempLogFile
echo . >> $TempLogFile
echo . >> $TempLogFile
echo . >> $TempLogFile

# logfile cleanup
cat $TempLogFile >> $LogFile
find ~/*.$ScriptName.log -ctime +14 -type f -print | xargs /bin/rm -f

 PostPosted: Tue Dec 12, 2006 2:31 pm   

Joined: Tue Dec 12, 2006 1:42 pm
Posts: 2
for now, i'm running a script in root's crontab to chown -R the appropriate directories to the appropriate user/group.


 PostPosted: Tue Dec 12, 2006 4:36 pm   

Joined: Wed Sep 06, 2006 12:19 pm
Posts: 54
Location: Covington, WA
Sounds like a possible permissions problem................Depending on how you have user accounts setup on the target machine, rsync (and scp) need to have identical user names for both source and destination.........Therefore, you should have an identical user account on the target machine already set up for the sender

I'm not sure what restrictions or policies are in place but, at the very least:
  1. Set up a special group ID on both machines and make the sender and the directories part of the same special group.
  2. Then make the source directory group writable (chmod g+w, or chmod 0775) on the directories.
  3. Now run the upload script as root one time to sync the target directory with the updated source. The sender should be able to sync the directory from then on.

This would probably be the best scenario since you will only need to set up the proper group ID once and simply assign whatever user you want to the special group, as needed......

That is, if it's a permissions problem....;-)

HTH :-)

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 5 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group