Migrating large number of pictures from DB storage to disk storage

3 years ago
For those of you who have sites that started out with storing pictures in the database, you likely know how painful (or impossible) it is to switch to disk storage.  It takes far too long and very likely you are hitting a 500 error after a short period of time because the process to move the pictures from the DB to disk takes a long time and the web request times out.  This leaves your pictures and configuration in an in-between state.  Some pictures were written to disk and cleared from the Picture table, but most weren't, and the setting controlling usage of DB/disk may or may not be updated.

I've written a command-line utility that can connect to your database and export the images to a local directory.  It can be run over and over until all pictures are exported.  There is also code to try to update the Picture table after the export.  However, with EF 6.x, there are reliability issues with very long running queries.  I'm working on fixes to these issues, but the code has been used on a v3.9 site with over 17K pictures with success.  I was required to manually update the Picture table to nullify the image storage and also update the setting to turn off DB picture storage, but the hard part was the export.


If you have any suggestions or would like to help, please do so through GitHub by either reporting issues, or forking and contributing code.

3 years ago
thats awesome!