Mac OS - running a bash script for rsync with different network credentials

2

I want to run rsync to copy files from local mac folders to a corporate network drive. To access the network drive I have to mount it using different credentials compared to my local user account.

How can I tell my bash script (that runs a few different rsyncs) to run as the other user (my corporate network user) to avoid getting forbidden (13) errors

failed: Permission denied (13)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-45/rsync/main.c(992)

EDIT:

Ok, so I created and mounted a share at ~/smb/pfimp/ - I can read the files perfectly fine, and it will create folders on the file server, but it can't copy the actual files over.

Any other suggestions? thanks

MAC:bin mylocaluser$ rsync -azP --exclude=.DS_Store ~/Documents/Work/Master/Scripts/demo/ ~/smb/pfimp/Scripts/demo
building file list ... 
38 files to consider
./
external/
external/workflow.py
        1225 100%    0.00kB/s    0:00:00 (xfer#1, to-check=35/38)
external/override/
external/override/before.py
        3229 100%    3.08MB/s    0:00:00 (xfer#2, to-check=33/38)
rsync: mkstemp "/Users/mylocaluser/smb/pfimp/Scripts/demo/external/.workflow.py.sEm5kg" failed: Permission denied (13)
rsync: mkstemp "/Users/mylocaluser/smb/pfimp/Scripts/demo/external/override/.before.py.iKs9MS" failed: Permission denied (13)

sent 2811 bytes  received 82 bytes  385.73 bytes/sec
total size is 31779  speedup is 10.98
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-45/rsync/main.c(992) [sender=2.6.9]

JPMox

Posted 2015-08-05T16:52:33.450

Reputation: 123

ps: changing the rsync command from your first post without mounting the share would be a solution, but if you are working on a Mac, then, at almost any time it would be better to mount the share and then copy files "locally" because that uses the apple provided software, the software that fit into your Apple pc, and that piece of software that apple improve instead of the standard Gnu rsync (it would mostly not be the standard Gnu rsync but apple does not improve those applets, but there own tools to mount and so on) – Schwertspize – 2015-08-10T17:32:12.390

Answers

0

You can use mount_afp to actually mount the share onto your computer, and afterwards use rsync (or another command) to copy your files to the share.

Usage:

mount_afp afp://yourserver/yourshare/folder mountpoint

if you use the smb protocol, you can use mount_smbfs

see the manpage of mount_afp and this one for mount_smbfs

EDIT rsync with the option -a has the problem that it tries to set permissions, but it can't because of the samba share. using the -r option instead of -a change that behavior.

Schwertspize

Posted 2015-08-05T16:52:33.450

Reputation: 335

thanks, although see my edit to the question - it still doesn't work. Any further suggestions? – JPMox – 2015-08-10T14:16:30.037

do you see the "Permission Denied?" I researched and found out that " Basically its because it trys to do it in archive mode, and I don’t have permission to change the permissions. So, if you remove the -a you should not see this error" – Schwertspize – 2015-08-10T16:15:52.963

brilliant, thanks so much! by using rsync -rzP (a to r) it didn't try to set permissions on the files on the server – JPMox – 2015-08-10T16:31:12.380