-
-
Notifications
You must be signed in to change notification settings - Fork 35
[feature] Runlevel option for schedule on Windows #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a very good point 👍🏻 I'll need to try it to understand how to create the task automatically. By that I mean what permissions are required to create the task (user password + elevated permissions?) |
How does resticprofile currently create the scheduled task? I don't know much go but if you can point me to the bit of code that does that, I can have a look if I have any idea how to implement this. |
Sure, I'd appreciate a bit of help 😉 To create a scheduled task on Windows, we create an XML file. The definition of the XML file is here: resticprofile/schtasks/settings.go Lines 9 to 27 in 669e77e
The object is created on this line, using the Config object as reference: resticprofile/schtasks/taskscheduler.go Line 54 in 669e77e
After that, we feed the XML file to the task scheduler using the command line: schtasks.exe /create /tn task_name /xml file.xml To understand which parameter to add or update, it's actually quite easy: you can prepare a task in the task scheduler, right click on it and choose There are also references to the MSDN documentation in some sections of the code. Good luck 😄 |
Small feature request: could we have a new option for
resticprofile schedule
that sets the "Run with highest privileges" checkbox in Task Scheduler? This also corresponds to/RL Highest
when using theSCHTASKS
cli command (https://superuser.com/questions/243605/how-do-i-specify-run-with-highest-privileges-in-schtasks).Why
Using
shcedule-permission: system
creates a task that runs as theSYSTEM
user. This provides all privileges (eg: create a VSS snapshot, access to all files), but creates issues to access network paths (eg. samba/cifs shares specified as\\server\\path\to\share
) that require credentials. TheSYSTEM
user does not have access to mapped drives, or credentials saved in the Windows Credential Manager created by a user, even from an elevated (run as administrator) shell. From my research, it seems that the only way to allow tasks running asSYSTEM
is to use a 3rd party tool (sysinternals PSExec) to run an elevated shell as theSYSTEM
user and a combination ofnet use
and/orcmdkey
. This feels a bit hackish. Another workaround would be to wrap theresticprofile backup
call in a script that first callsnet use /user:... /password:...
to connect the network path with the given credentials.Running the scheduled task as a user allows access to the network path with saved credentials, but does not provide sufficient privileges to use the VSS snapshot option, or backup "system" files.
The workaround is relatively simple, that is, after running
resticprofile schedule
withschedule-permission: user
, I go into the task scheduler and manually check theRun with highest privileges
. Since runningschedule
is not something we do very often, this is not a huge deal. Maybe just adding a note to the docs would be OK too.The text was updated successfully, but these errors were encountered: