FreeFileSync not working with Windows Task Scheduler

Get help for specific problems
Posts: 4
Joined: 1 Jun 2019

thonk

Greetings,

Here's what I want to do: Automatically backup files & folders from cloud through SFTP to a local computer by using Windows Task Scheduler. For this, I created two batch jobs, each of which will mirror the files to separate folders on the local computer. Each batch job has its own task on Windows Task Scheduler and will run on highest privileges, etc.

Here's the problem: The tasks seem to work as far as changing the last edited timestamps of the target folders, but the timestamps of the actual files inside the two target folders aren't changing. So it seems that the tasks are triggered daily, but for some reason, the actual backup isn't happening. The batch jobs themselves seems to be working fine every time I trigger them manually.

I don't know what to do next. Any help would be appreciated. Thanks!
User avatar
Posts: 2290
Joined: 22 Aug 2012

Plerry

The log-file should tell you what changes FFS made, and possibly, what changes FFS was not able to make and why not.
Note that the location of the log-file may depend on the user credentials under which you run the scheduled task.
Posts: 4
Joined: 1 Jun 2019

thonk

Hi,

Thank you for the answer. I now located the log files. It appears that when I click the batch jobs manually, it works fine and there are no errors. However, when it is supposed to be triggered by Windows Task Scheduler, it gives an error every time. From what I understand, it complains about the SSH key and the agent:

LIBSSH2_ERROR_AGENT_PROTOCOL: agent list id failed [libssh2_agent_list_identities]

I wonder if Windows Task Scheduler lacks the rights to perform the batch job?
User avatar
Site Admin
Posts: 7056
Joined: 9 Dec 2007

Zenju

You're using the "Pageant" authentication mode with SFTP, which let's FFS communicate with the process of the same name. My guess is that for this to work you have to impersonate as the same user when using Windows Task Scheduler as you are in your manual tests.
Posts: 4
Joined: 1 Jun 2019

thonk

Thank you for the tip. However, I don't quite understand how I should approach this. When I go to Windows Task Scheduler and open the task, there's the option to select the user. The user is the same I performed the manual tests on, as I didn't log out and switch users or anything like that.

If I used an authentication mode other than "Pageant", would it work better with FFS? However, Pageant seemed to be the only way to make the connection to work, so I don't know what to do about that.
User avatar
Site Admin
Posts: 7056
Joined: 9 Dec 2007

Zenju

You also have to uncheck "Run with highest privileges". I assume the issue is similar to: https://freefilesync.org/faq.php#task-scheduler-network
Posts: 1
Joined: 6 Jun 2019

avian

I had a similar problem. If I ran the task with the SYSTEM user, the job would start, but the backup would fail because the system user didn't have access to the networked storage that I was trying to back up to. If I created the task under my own user, the job never ran. I could start the backups manually, but they wouldn't start on a schedule.

The problem appears to be an obscure setting in the Power section of the Windows settings. There you'll find a setting for what tasks are allowed to wake up the computer. In the two systems I was working on, it was set to only allow "important" tasks to wake the computer. See the second solution in this article for complete details, with pictures: https://windowsreport.com/task-scheduler-wont-turn-on-pc/

I also saw something in another article that said something to the effect that creating a "Basic Task" in task scheduler didn't or might not have the capability to wake the computer, even though that option is presented in the settings. To err on the side of caution, I created normal tasks and didn't use the basic task wizard.

My tasks all have the "Run with highest privilege" set and they seem to run. YMMV.

I also ran into some strange behavior with task scheduler. If I set the task to only execute when it was connected to a specific network, the task scheduler couldn't connect to the scheduling service. I'm going to reinvestigate that one. Some articles also said that requiring the computer to be on A/C power before starting caused a problem as well.

I do not use FTP/SFTP for my backups, just straight network copies or copies to USB drives.

I think that once you change the setting about what tasks are allowed to wake the computer, you'll have better luck with task scheduler.
Posts: 4
Joined: 1 Jun 2019

thonk

Hey! Thank you for all the advice. By disabling the "Run with highest priviledges option" on WTS I seem to have gotten rid of errors in the FFS logs. I will monitor how the automatic backup work, but this is a little victory on the way. 😎