Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 3032  / 1 Year ago, tue, january 10, 2023, 11:58:12

Hi I am attempting to use rsync to copy files between two linux servers. both on 10.04.4



I have set up the ssh and a script running under a cron job. this is the message i get back from the cron job.




To: mark@ubuntu Subject: Cron ~/rsync.sh Content-Type:
text/plain; charset=ANSI_X3.4-1968 X-Cron-Env:
X-Cron-Env: X-Cron-Env:
X-Cron-Env: Message-Id:
<20120708183802.E0D54FC2C0@ubuntu> Date: Sun, 8 Jul 2012 14:38:01
-0400 (EDT)



rsync: link_stat "/home/mark/#342#200#223rsh=ssh" failed: No such
file or directory (2) rsync: opendir
"/Library/WebServer/Documents/.cache" failed: Permission denied (13)
rsync: recv_generator: mkdir "/Library/Library" failed: Permission
denied (13)
* Skipping any contents from this failed directory * rsync error: some files/attrs were not transferred (see previous errors) (code 23)
at main.c(1060) [sender=3.0.7]




Q.1 can anyone tell me why I get this message -->



rsync: link_stat "/home/mark/#342#200#223rsh=ssh" failed: No such file or directory (2)



the script is:



    #!/bin/bash
SOURCEPATH='/Library'
DESTPATH='/Library'
DESTHOST='192.168.1.15'
DESTUSER='mark'
LOGFILE='rsync.log'
echo $'

' >> $LOGFILE
rsync -av –rsh=ssh $SOURCEPATH $DESTUSER@$DESTHOST:$DESTPATH 2>&1 >> $LOGFILE
echo “Completed at: `/bin/date`” >> $LOGFILE


Q2. I know I have several problems with the permissions all of the files I am copying usually require me to use sudo to manipulate them. My question is then is there a way i can run this job without giving my user root access or using root in the login ??



Thanks for the help .


More From » permissions

 Answers
5

As for Q1 I'm guessing that you have put the double dash before "rsh" in as an "en-dash", i.e. a single character: — so rsync is interpreting it as a filename rather than an option to the program.



For Q2 if you want to give a non-root user permission to do things with files it wouldn't otherwise be able to manipulate you're either going to have to change the permissions of the files or elevate the permissions of the user, e.g. through use of sudo.



sudo can be configured to allow certain users to execute certain commands as root with no password prompt, so the thing you need to do is separate out the things you need to do as root into a script which does them (and only them), and then allow that script to be called as root. Here is an example from one of my /etc/sudoers files:



Cmnd_Alias      F2B_CLIENT_PING = /usr/bin/fail2ban-client ping
nagios ALL = NOPASSWD: F2B_CLIENT_PING


What the above does is allows the "nagios" user to execute "/usr/bin/fail2ban-client ping" as root using sudo, without being prompted for a password. I use it in my monitoring.



You'd have something like:



Cmnd_Alias RSYNC_BACKUP = /usr/local/sbin/backup_my_stuff_with_rsync.sh
youruser ALL = NOPASSWD: RSYNC_BACKUP


and then in your cron you'd call sudo /usr/local/sbin/backup_my_stuff_with_rsync.sh



You can test it on the command line first to verify that it doesn't ask for password.



Note that running a script as root is a big deal and so you must ensure that your script is secure and correct. If you can find any way to do this as non-root, that would be better.


[#36998] Wednesday, January 11, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingsta

Total Points: 391
Total Questions: 103
Total Answers: 124

Location: Bonaire
Member since Wed, Mar 29, 2023
1 Year ago
ingsta questions
Sun, Oct 23, 22, 01:42, 2 Years ago
Sat, Oct 30, 21, 11:27, 3 Years ago
Sun, Nov 28, 21, 12:49, 2 Years ago
;