Today I was in the middle of testing how our environment works with large content databases and ran into an issue with the command Export-SPWeb and large data sets. This might be known already do some of you, but I have been working with SharePoint a long time and didn’t know this, so wanted to share in case others ran into the same or similar problem.
Backing up a single list in a SharePoint site. The list is populated with a huge number of picture files (all copies of each other). To export the data I ran the command:
Export-SPWeb -Identity "<Site URL>" -ItemUrl "/Pictures/" -Path "Z:\ListBackup\Pictures.cmp"
During the backup, was keeping an eye on the logs and the drive I was backing up to. The log file was created, but for some reason nothing was being exported into the drive. When viewing the log file I saw the files were in fact being copied out of the library:
So where were they going? I started taking a look at my C drive as that to me was the next logical place the export would be dumping to. I could see that space was being eaten up somewhere in the system drive. After some digging I found a GUID named folder in the user profile temp folder. In it was a series of .dat files all the same size as the picture files I had in the library.
This, plus the fact it was still filling with .dat files allowed me to deduce that my export was actually first going here before being moved to my chosen path location.
If you are savvy with the shortcuts for internal locations of Windows files this location is “%USERPROFILE%\AppData\Local\Temp”. The problem now, is that the data I was backing up was about 10 times the amount of space I had available to me on my system drive. So I would expect to very quickly receive an error in the neighborhood of “not enough disk space”.
For the purpose of running the Export-SPWeb command and large data sets I suggest modifying the path for the Temp directory to a drive that contains enough space to handle the export. To do this modify your server’s System Properties and update the Environmental Variables for TEMP. I chose to modify TMP as well, but you probably don’t need to:
Once you have completed the export, I strongly suggest you put it back. If you don’t then you could run into a problem when someone else is troubleshooting, the logs generated aren’t going to be where they expect them to be.
Hope this helps prepare you in the future.
Thanks for reading!