restic-windows-backup icon indicating copy to clipboard operation
restic-windows-backup copied to clipboard

Windows Task Scheduler doesn't process config.ps1

Open LasoGit opened this issue 4 years ago • 12 comments
trafficstars

EDIT: see last post

Dear Kevin,

many thanks for your work! I followed your installation instructions successfully until defining $BackupSources in config.ps1.

This will back up C:\ entirely:

$BackupSources = @{} $BackupSources["C:"] = @(

'Users'

)

I only want to include a specific folder and can't manage to replace the # 'Users' line with C:\path\to\folder Can you please advise? Sorry for raising this as an issue, I searched the forum to no avail and think this is the best place to look for an answer...

LasoGit avatar Sep 23 '21 11:09 LasoGit

@LasoGit You have to explain the problem. What do you mean by "can't manage to replace the # 'Users' line"? It's just a line of text - replace it using a text editor?

rawtaz avatar Sep 23 '21 12:09 rawtaz

@rawtaz Sorry for not explaining the issue concisely. Following the instructions, I successfully initialized a new repo (step 4 ii.) so assume I did everything right up to that point. In step 5, I changed the default $BackupSources in order to only backup "folder123" and not the entire drive C:. I replaced lines 27-30 in config.ps1 with this:

$BackupSources = @{} $BackupSources["C:"] = @( users\user\path\to\folder123 )

I omitted step 6 (nothing to exclude), followed step 7 (exclusion from win detection) and finally triggered the task manually in Task Scheduler. In the Task Scheduler, "Restic Backup" shows as "running", but nothing happens except for empty error logs appearing in

LasoGit avatar Sep 23 '21 14:09 LasoGit

Is it possible that you're simply missing the single quotes around that path? I mean, the line should probably read 'users\user\path\to\folder123' and not users\user\path\to\folder123, considering the 'Users' you had there before was quoted (and also that it makes sense from a programming/scripting language perspective that the string needs to be quoted). Please try that and see if it helps.

Restic initializes a repository without having to deal with the backup paths you specify here, so they have no relation at all.

rawtaz avatar Sep 23 '21 14:09 rawtaz

Thanks again for your answer! I tried again with the single quotes 'users\user\path\to\folder123' but it still doesn't work. I will wait a good bit longer to make sure that Task Scheduler is not still working on the task (backing up this folder manually took only about 2 minutes). It seems strange to me that the xxx.err.txt files in

LasoGit avatar Sep 23 '21 14:09 LasoGit

PowerShell can sometimes delay the output into the .log and .err files; it's a bit annoying. It's possible it's running just fine, but not dumping to the logs. One way you can test is to just run the .\backup.ps1 script from an elevated PowerShell prompt and see if it runs and then completes. One way I check to see if a backup is running is by looking at the target repository files and confirm that (1) the lockfile keeps getting updated (usually every ten min) and (2) more files continue to get added to the repository. You can find the lockfile in the <repository>\locks folder. If there's no lockfile there, then there's no backup running. If there's a lockfile, look at the date - it should keep getting updated if a backup is running. Another thing to test is a very small folder, just to confirm it backs up and runs for a very small data set. HTH

On Thu, Sep 23, 2021 at 7:58 AM LasoGit @.***> wrote:

Thanks again for your answer! I tried again with the single quotes 'users\user\path\to\folder123' but it still doesn't work. I will wait a good bit longer to make sure that Task Scheduler is not still working on the task (backing up this folder manually took only about 2 minutes). It seems strange to me that the xxx.err.txt files in

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kmwoley/restic-windows-backup/issues/53#issuecomment-925894923, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOWG6ADS62H5CJEPWIDDIDUDM6ALANCNFSM5ETOW7TA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kmwoley avatar Sep 23 '21 16:09 kmwoley

I'm not new to restic, but this is my first reply to the list.

Have you tried using a complete path, starting from the root?

The users I backup in Windows have their folders defined as

"C:\Users*\Desktop C:\Users*\Documents C:\Users*\Downloads C:\Users*\Pictures"

In your case it would be

'C:\users\user\path\to\folder123'

Bill Bardon COMPUTASSIST, LLC Omaha, Nebraska

On Thu, Sep 23, 2021, at 9:58 AM, LasoGit wrote:

Thanks again for your answer! I tried again with the single quotes 'users\user\path\to\folder123' but it still doesn't work. I will wait a good bit longer to make sure that Task Scheduler is not still working on the task (backing up this folder manually took only about 2 minutes). It seems strange to me that the xxx.err.txt files in

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kmwoley/restic-windows-backup/issues/53#issuecomment-925894923, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADJTDY64MGLH56VQQXSIHW3UDM6ALANCNFSM5ETOW7TA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

BillBardon avatar Sep 23 '21 16:09 BillBardon

@kmwoley Thanks for the response! I ran the .\backup.ps1 script from PowerShell and it worked fine, taking about 2 minutes in total. 👍 I waited over an hour for Task Scheduler to finish, so the problem seems to be with Task Scheduler - I checked the Restic Backup task's properties and found these arguments: -ExecutionPolicy Bypass -NonInteractive -NoLogo -NoProfile -Command ".\backup.ps1; exit $LASTEXITCODE" These seem to be all default values - I double checked by running the whole script installation again. Do you have any other idea what may cause this issue?

Edit: I started the task again in Task Scheduler and checked the backup repository about 10 minutes later - no lock file to be found in /locks, and no new data files newer than those created by the manual script run you recommended.

LasoGit avatar Sep 23 '21 17:09 LasoGit

@BillBardon Thanks for the response! The path I put in last 'users\user\path\to\folder123' works fine with the script itself, the problem seems to be with Windows Task Scheduler (see my response above).

LasoGit avatar Sep 23 '21 17:09 LasoGit

@lasogit - Those run arguments look right to me. Try running Task Scheduler again and see what happens. Try right-clicking and selecting "End", and then "Run" and see what happens.

On Thu, Sep 23, 2021 at 10:11 AM LasoGit @.***> wrote:

@BillBardon https://github.com/BillBardon Thanks for the response! The path I put in last 'users\user\path\to\folder123' works fine with the script itself, the problem seems to be with Windows Task Scheduler (see my response above).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kmwoley/restic-windows-backup/issues/53#issuecomment-926001431, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOWG6B5ZGDIMQBYRLX5IU3UDNNU7ANCNFSM5ETOW7TA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kmwoley avatar Sep 23 '21 17:09 kmwoley

@kmwoley I did that several times to no avail, also running Task Scheduler with elevated privileges. Just to be sure I rebooted my system and found no differences:

  • running .\backup.ps1 directly from PowerShell works fine, takes about 2 mins and writes a xxx.log.txt
  • manually starting the task in Task Scheduler just triggers 4 events [right click > properties > history] within 1 second:

events Sorry for posting a screenshot with german text - they translate roughly to "129 - process for created task", "100 - task has been started", "200 - action has been started", "110 - task was triggered by user".

20 minutes later, I find no changes in the repository and no new events in Task Scheduler.

LasoGit avatar Sep 23 '21 18:09 LasoGit

@LasoGit - did you ever get this sorted out? I do wonder if there's an issue caused by localization somehow. Unfortunately I don't know what more I can do to help you out. If you found a solution, please post it here.

kmwoley avatar Nov 15 '21 04:11 kmwoley

@kmwoley I couldn't solve the issue so I decided to write my own (much simpler) script in Bash (I'm using Ubuntu/WSL2 on Windows 10) and start the bash script via Task Scheduler automatically which works fine. Sorry for not updating the issue, thanks for asking!

LasoGit avatar Nov 15 '21 13:11 LasoGit

Closing this issue out given it's age and status.

kmwoley avatar Jan 15 '23 05:01 kmwoley