Back up your device without vendor lock-ins, using insecure software or root. Supports encryption and compression out of the box. Works cross-platform.
Available disk space: hundreds of gigabytes
Operating system: Windows 11
Describe the issue below.
The "Converting files - this may take several minutes..." step was taking a long time, so I cancelled it and did some digging, and it looks like when I ran the script directly from my Windows home directory (which was the CWD), it would then open the WSL instance at that directory and consequently the find command was running on my entire Windows C:\Users\ folder, then dos2unix would have also ran on every .sh file in that entire folder if the execution had continued.
I think this happens because the powershell script doesn't check the CWD (or switch the CWD to the script directory), and when running wsl bash -c '....' or wsl anything for that matter it takes the CWD as whatever the CWD was it was called from, as seen below:
This is quite dangerous as all it takes is for someone to have a PowerShell already open and drag/drop the script onto the PowerShell window (which automatically copies the path of the file into the console, enabling you to run it just by hitting enter) and the script will then execute on whatever directory they were in, which by default in PS is their entire home directory.
Also, the rest of the script would have failed as it has relative paths referencing files in the script's directory.
This can easily be fixed I think by adding Set-Location -Path $PSScriptRoot to the backup-windows.ps1 script. I will test this out and if it works I will make a PR.
System info
Available disk space: hundreds of gigabytes Operating system: Windows 11
Describe the issue below.
The "Converting files - this may take several minutes..." step was taking a long time, so I cancelled it and did some digging, and it looks like when I ran the script directly from my Windows home directory (which was the CWD), it would then open the WSL instance at that directory and consequently the folder, then dos2unix would have also ran on every .sh file in that entire folder if the execution had continued.
find
command was running on my entire Windows C:\Users\I think this happens because the powershell script doesn't check the CWD (or switch the CWD to the script directory), and when running
wsl bash -c '....'
or wsl anything for that matter it takes the CWD as whatever the CWD was it was called from, as seen below:This is quite dangerous as all it takes is for someone to have a PowerShell already open and drag/drop the script onto the PowerShell window (which automatically copies the path of the file into the console, enabling you to run it just by hitting enter) and the script will then execute on whatever directory they were in, which by default in PS is their entire home directory.
Also, the rest of the script would have failed as it has relative paths referencing files in the script's directory.
This can easily be fixed I think by adding
Set-Location -Path $PSScriptRoot
to the backup-windows.ps1 script. I will test this out and if it works I will make a PR.