Leon Vanderploeg
2020-Mar-28 21:29 UTC
Rsync to Network Share works from cmd but fails from Scheduled Task
Greetings, I have written a C program that runs on Windows servers and does overhead and reporting for backup administration. The program calls rsync for the actual data copy function. It copies data from a remote system to a local drive and that works fine. However, I have recently made changes to copy the data to a mapped drive on a NAS device instead of the local drive. The changes work fine when run from a command line, but fail when run from a scheduled task or cron job: rsync: mkdir "/cygdrive/q/restores" failed: No such file or directory (2) rsync error: error in file IO (code 11) at main.c(675) [Receiver=3.1.2] Note: The folder already exists and permissions are open for Administrator. Command line that works is bash command to call the C program under Administrator login. Scheduled task built as Administrator with or without highest privileges fails. Tried Cron entry built under Administrator and it fails. Here is the Rsync command (abbreviated) called by the C program: rsync -rltgoD --chmod=Du+w,u+r,u+x -e "ssh -p 33222 -i \"/cygdrive/c/Users/administrator/.ssh/id_rsa\"" --stats --files-from=/... -vv --exclude-from=/.... <usr>@remote:/<remote_loc> /cygdrive/q/restores Note: q is the mapped drive to the NAS share. So, what can be done to track this down? Why would running as a scheduled task or cron job fail when command line works? I am willing to do any kind of tracing if someone can provide directions on how to do that. Thanks in advance, Leon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20200328/fcf570d4/attachment.htm>
raf
2020-Mar-30 03:23 UTC
Rsync to Network Share works from cmd but fails from Scheduled Task
Leon Vanderploeg via rsync wrote:> Greetings, > > I have written a C program that runs on Windows servers and does overhead > and reporting for backup administration. The program calls rsync for the > actual data copy function. It copies data from a remote system to a local > drive and that works fine. However, I have recently made changes to copy > the data to a mapped drive on a NAS device instead of the local drive. > > The changes work fine when run from a command line, but fail when run from > a scheduled task or cron job: > rsync: mkdir "/cygdrive/q/restores" failed: No such file or directory > (2) > rsync error: error in file IO (code 11) at main.c(675) [Receiver=3.1.2] > Note: The folder already exists and permissions are open for Administrator. > > Command line that works is bash command to call the C program under > Administrator login. > Scheduled task built as Administrator with or without highest privileges > fails. > Tried Cron entry built under Administrator and it fails. > > Here is the Rsync command (abbreviated) called by the C program: > rsync -rltgoD --chmod=Du+w,u+r,u+x -e "ssh -p 33222 -i > \"/cygdrive/c/Users/administrator/.ssh/id_rsa\"" --stats --files-from=/... > -vv --exclude-from=/.... <usr>@remote:/<remote_loc> /cygdrive/q/restores > > Note: q is the mapped drive to the NAS share. > > So, what can be done to track this down? Why would running as a scheduled > task or cron job fail when command line works? I am willing to do any kind > of tracing if someone can provide directions on how to do that. > > Thanks in advance, > LeonHi, I think the most likely reason is that when you execute the command interactively, you are logged into Windows locally and your cached credentials are used to connect to the mapped drive. But that's not the case when the task is scheduled, and so the mapped drive isn't mapped when the scheduled task is attempted. Similarly, with Cygwin, you can only see /cygdrive/q/... while you are accessing it locally. If you ssh to a Windows host with Cygwin and sshd running, you can't see any mapped drives that are accessible to the local user, even if you ssh in as the same user. You will have to map the drive in the scheduled task before invoking rsync, and then unmap the drive afterwards. I don't know how to do that or handle the credentials that would be needed, but I think that's where to look. cheers, raf
Leon Vanderploeg
2020-Apr-02 15:56 UTC
Rsync to Network Share works from cmd but fails from Scheduled Task
Hi raf, I was not aware the network maps were "user experience". Thanks for your tips. I have tried everything I can come up with, but cannot get it to work. I figured out another solution, but thank you very much for your help. Best, Leon On Sun, Mar 29, 2020 at 9:23 PM raf via rsync <rsync at lists.samba.org> wrote:> Leon Vanderploeg via rsync wrote: > > > Greetings, > > > > I have written a C program that runs on Windows servers and does overhead > > and reporting for backup administration. The program calls rsync for the > > actual data copy function. It copies data from a remote system to a > local > > drive and that works fine. However, I have recently made changes to copy > > the data to a mapped drive on a NAS device instead of the local drive. > > > > The changes work fine when run from a command line, but fail when run > from > > a scheduled task or cron job: > > rsync: mkdir "/cygdrive/q/restores" failed: No such file or directory > > (2) > > rsync error: error in file IO (code 11) at main.c(675) > [Receiver=3.1.2] > > Note: The folder already exists and permissions are open for > Administrator. > > > > Command line that works is bash command to call the C program under > > Administrator login. > > Scheduled task built as Administrator with or without highest privileges > > fails. > > Tried Cron entry built under Administrator and it fails. > > > > Here is the Rsync command (abbreviated) called by the C program: > > rsync -rltgoD --chmod=Du+w,u+r,u+x -e "ssh -p 33222 -i > > \"/cygdrive/c/Users/administrator/.ssh/id_rsa\"" --stats > --files-from=/... > > -vv --exclude-from=/.... <usr>@remote:/<remote_loc> /cygdrive/q/restores > > > > Note: q is the mapped drive to the NAS share. > > > > So, what can be done to track this down? Why would running as a > scheduled > > task or cron job fail when command line works? I am willing to do any > kind > > of tracing if someone can provide directions on how to do that. > > > > Thanks in advance, > > Leon > > Hi, > > I think the most likely reason is that when you execute > the command interactively, you are logged into Windows > locally and your cached credentials are used to connect > to the mapped drive. But that's not the case when the > task is scheduled, and so the mapped drive isn't mapped > when the scheduled task is attempted. > > Similarly, with Cygwin, you can only see > /cygdrive/q/... while you are accessing it locally. If > you ssh to a Windows host with Cygwin and sshd running, > you can't see any mapped drives that are accessible to > the local user, even if you ssh in as the same user. > > You will have to map the drive in the scheduled task > before invoking rsync, and then unmap the drive > afterwards. I don't know how to do that or handle the > credentials that would be needed, but I think that's > where to look. > > cheers, > raf > > > -- > Please use reply-all for most replies to avoid omitting the mailing list. > To unsubscribe or change options: > https://lists.samba.org/mailman/listinfo/rsync > Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20200402/0374013b/attachment.htm>
Possibly Parallel Threads
- Rsync to Network Share works from cmd but fails from Scheduled Task
- Rsync to Network Share works from cmd but fails from Scheduled Task
- Behaviour of /./ in from file on version 3.0.4
- DO NOT REPLY [Bug 6116] New: Cannot access files in exposed shadow drive in version 3.0.5
- Help - rsync runs from command line, fails from task scheduler, hangs at msg checking charset: UTF-8