WSL --export $filename as string variable

Timy Shark 21 Reputation points
2022-06-01T02:59:58.213+00:00

I wish I can automate my backups by running automated script every night to back my wsl container, so
I tried to create a ps1 file
$today = Get-Date -Format "ddmmyyHHmm"
wsl --export mywsl "D:\backup"$today

The above generates an error , directory or file is not formated. so how to pass filename to the wsl --export command?
thanks.

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. MotoX80 36,901 Reputation points
    2022-06-01T20:34:47.497+00:00

    Try this.

    wsl --export mywsl "D:\backup$today"
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.