Sync Steam Game Library to NAS using PowerShell
Steam or similar platforms make installing many games quick and easy, but maintaining a large library of games over time can lead to a lack of disk space as most gamers know. With titles like Microsoft Flight Simulator (140GB+) & Call of Duty (80GB+), this becomes even more of an issue sooner.
If your lucky enough to have a NAS with abundant space, or are willing to add one, you can back up your games there.
This allows you to delete some when you need to make room without them being lost on the NAS, and if you want them back you simply copy that game back to your Steam library, then click the install button in Steam. It will scan the files and update only what is needed.
But copying games every time Steam pushes updates can be a tedious and time consuming task.
I wrote the following PowerShell script to simplify & automate this process. Once you set the paths it will auto sync all games in your library to the NAS.
It does this by looping over each game folder in your library and mirroring it to your NAS game library using the Robocopy.exe command.
We loop over each game separately as we are using mirror copy which would delete games on the NAS that didn’t exist locally if we did it on the library directly. But mirror
mode is excellent at keeping a direct & up to date copy on the NAS without leaving extra files.
In the code below I also took advantage of the small speed boost for mapped network drives
, so G:\
represents a share on my NAS specifically for game libraries.
Set it to run overnight and your all set. If you have a large library or slow network connection to the NAS this can take some time.
Side note, this could also be used to move games from an SSD to a slower HDD, if you wanted you could even modify it to add symbolic links and play games from the other folder.
I am a founder & CEO of Code Atlantic and I've been working with WordPress for over 15 years creating plugins to help WP site owners grow for more than 10 of those. We have developed and maintained popular plugins including the best wordpress popup plugin, Popup Maker with over 4k 5 star reviews, as well as Content Control, Ahoy & User Menus.