Everything I install inside a WSL distro lives in one place that is easy to forget about when making backups. WSL can write the whole thing to a single file.
First look up the exact name with wsl --list. Then stop the distro so files aren’t changing, and export it:
wsl --terminate Ubuntu
wsl --export Ubuntu D:\Backups\ubuntu.tar
The default format is tar. On WSL 2 you can add --vhd to get a .vhdx virtual disk instead.
To bring it back, or to make a throwaway copy for an experiment, import the file under a new name and give it a folder to live in:
wsl --import Ubuntu-test D:\WSL\Ubuntu-test D:\Backups\ubuntu.tar
Now you have two separate systems, and you can break the second one without worry.
Two things to keep in mind. The tar file contains everything in the distro, including SSH keys, tokens and shell history, so store it somewhere you trust. And an imported distro has no launcher program, which means the usual config --default-user command doesn’t work for it. Set the default user in /etc/wsl.conf inside the copy if it starts as root.
Further reading: Basic commands for WSL