creativeprojects / resticprofile

Configuration profiles manager and scheduler for restic backup
https://creativeprojects.github.io/resticprofile/
GNU General Public License v3.0
592 stars 29 forks source link

Problem with path spaces on windows using pwsh #230

Open tekert opened 1 year ago

tekert commented 1 year ago

So, im trying to backup chrome - resticprofile version 0.22.0 commit ddf9debf89960db2c6139523ef6140a6538c5d27 using:

global:
  shell: pwsh
...
source:
  - "E:\\Data\\Tekert\\AppData\\Local\\Chrome\\User\ Data"
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping


...
source:
  - "E:\\Data\\Tekert\\AppData\\Local\\Chrome\\User Data"
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping


...
source:
  - 'E:\Data\Tekert\AppData\Local\Chrome\User Data'
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping


...
source:
  - E:\Data\Tekert\AppData\Local\Chrome\User Data
...

E:\Data\Tekert\AppData\Local\Chrome\User does not exist, skipping Data does not exist, skipping

tekert commented 1 year ago

Additionaly same problems with:

restic-binary: "C:\\Program Files\\WinGet\\Links\\restic.exe"

C:\Program: The term 'C:\Program' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

jkellerer commented 1 year ago

The issue with restic-binary is known and fixed in #224 (next release). Interesting that additional command options seem to be interpreted as shell markup as well. We already pass individual parameters (like paths) as escaped tokens, but it seems they are interpreted as powershell markup.

Before #224 is enhanced (and available), you can workaround the issue by escaping paths manually using the pwsh escape char [`]. E.g.:

source:
  - E:\Data\Tekert\AppData\Local\Chrome\User` Data
tekert commented 1 year ago

Oh i see, [`] is working for now. except restic-binary path

tekert commented 1 year ago

There is another problem with cmd shell this time, maybe its related,

a powershell script named myscript.ps1 with

param (
    [string] $param1,
    [string] $param2 = "a default path"
)
Write-Output "param1=$param1"
Write-Output "param2=$param2"

Called from a yaml profile with this:

global:
  shell: cmd
...
      run-before:
        - >
          powershell -ExecutionPolicy Bypass -File myscript.ps1
          -param1 <a dir with spaces>
          -param2 "<a dir with spaces>"
...

Result:

param1=<a
param2="<a