In this tutorial, you will learn how to backup Umbraco assets. A common question by people new to Umbraco is, where are my media and images stored? The quick and simple answer to this question is within the websites webroot within the /media folder:

Where Are Media Files Stored In My Umbraco Website 1

As media is stored directly on the server there is a potential that if the files got deleted from the server you would lose them forever! How will you ensure that this does not happen? Another challenge with assets management occurs if you run Umbraco using a load-balanced configuration, with multiple servers. If you have a really popular website, your web server might not be able to cope with the traffic. One way of dealing with this load is to buy an additional webserver to try to prevent any bottlenecks (I won't go over the details of load balancing here, but you can find more information in How To Configure Umbraco To Work In A Load-Balanced Environment). In a load-balanced environment, if a content editor uploads a media item, out-of-the-box, that item would only be uploaded onto one of the servers. If a website user tried to view an image and got directed to a server in the cluster that didn't have contain that image, they would see a missing image. This is obviously a 💩experienceThe question we need to answer is, how do you ensure assets are synced correctly after a content editor uploads something? Read on to learn more!

How To Deal With Umbraco Media Files In A Load-Balanced Set-up?

Out of all the CMS systems I've used, Umbraco probably has the most diverse usage range. I work with clients that range from people wanting to start their own website, to large corporate companies that use Umbraco as the face of their online presence. If you run your own hobby site and your website only contains a handful of pages, you may not care if you lose a few images. Let's be honest, you probably will. Now scale this in importance for a business, having a media backup plan is an essential task!

One way to get around this issue is to use a NAS (Network Attached Storage). A NAS can be thought of as a shared hard drive that all your web servers communicate with. When someone uploads an image, it gets copied to the NAS instead of the individual server and every server in the web farm will get instant access to it. For this tutorial, I will assume that this is the direction you want to take. I will also not tell you how to set up a NAS, only how to configure Umbraco to work with one! How then do you configure Umbraco to use a different media folder?

How To Change The Media Folder Location

If you look in the config directory within your webroot, you should see a file called FileSystemProviders.config.

Where Are Media Files Stored In My Umbraco Website 2

In here you will see some configuration that looks like this:

There are a few ways to configure this. If you want to simply want to use a different folder to host the media you can update virtualRoot. If you want to use a file path rather than a virtual directory, you might need to look into adding rootPath and rootUrl. rootPath is the file location to your NAS and the rootUrl is the Url Umbraco will mask in order to link to it. Changing these values will mean you can point to the NAS shared directory rather than use the folder in the webroot. using a NAS is a better solution. You can then use a NAS backup solution to ensure your files are not lost. All servers in a load-balanced environment will get instant access to the media assets, job is done! You could also use an additional file provider like an S3 bucket, or Azure storage, however, that is for another tutorial. Before we go here are some further tips!

Umbraco Media Management Tips

If you have a site with a lot of content, after a few years the media can grow epically. I strongly recommend clearing the recycle bin every month. In some extreme cases, I've seen older versions of Umbraco hit a capacity limit because the recycle bin becames too large! As a consequence, the website would constantly crash, as the CPU would throttle to around 95% usage 😢. Remember, do not plonk everything within a single root folder side of the CMS. Organize the Media section into sub-folders for optimal usage! Happy Coding 🤘