If like me you have many different catalogues within Lightroom then you might get lazy when it comes to backing up your Lightroom Catalogues. As you may know, the catalogue stores all of the non-destructive editing carried out on your photos. Lose the catalogue and you lose the edits. Catalogues have to be stored locally and therefore is not easy to have them stored on resilent network storage such as a NAS.
I was getting concerned that I didn’t backup my catalogues often enough and decided to fix it once and for all and even turn off the backup notifications in Lightroom. I created a simple method to automatically backup any changes to my catalogues each time I log off or shut down my PC, please note, it doesn’t run if you just sleep or hibernate. As I’ve got an SSD in my PC it boots so quickly that I always shut it down when not using it.
Yes, this is important, I said “my PC”, I’m not a MAC user so this is not relevant to MACs but I suspect there is something similar available. Although I’m using Windows 10, this method should still work for 7 and 8. Please note, you require access to the Group Policy Editor, this is not available in “Home” versions of Windows and requires you are running a “Pro” version of Windows.
I’ve recorded a How To Video complete with written instructions below
So, my catalogues are all stored locally in a folder within My Documents called Lightroom Catalogues and it’s important to have them stored in the correct structure.
Lets take a look inside one of the folders as it’s important to know what requires backing up.
In the example above you will notice the .lrcat file, this is the actual catalogue which is a database of image details and any edits made to them (It doesn’t include any images themselves). This is the file that is copied when you perform a backup within Lightroom. The folder which ends in Previews.lrdata has multiple subfolders and files inside, these contain the preview files and are not required to be backed up as they will simply be regenerated when you open the catalogue file. Also, due to the multiple files and folders, these would take a long time to backup.
Therefore to conduct an automated backup, it’s not a case of copying the entire folder containing the catalogues but the main folder, each separate catalogue folder and the .lrcat file in each of these but not the Previews.lrdata folder and contents.
Windows has a built in command called Robocopy which is a powerful file management tool. It also has a great feature in that it can copy a folder with it’s contents stating the number of subfolders you want to include. Perfect for what we are trying to achieve.
So, with the folder structure in place (referring back to the first screenshot showing the catalogue folders) we require to copy the folder called “Lightroom Catalogs”, all of the subfolders (Catalogue names) and the files (in this case the .lrcat) inside the subfolders, but not any further down the structure. So as far as Robocopy is concerned that is 2 levels deep.
I have a NAS (Network-attached Storage) which is a box with redundant hard drives that I store all my files (including photos) and also where I backup my Lightroom Catalogues. On my PC this is the Z: drive, this process will also work for any external hard drive, memory stick, memory card, 2nd Hard Drive (basically anything with a drive letter) you may have attached. However, you will notice below that I reference the Q: drive for my NAS. You just need to substitute this drive letter for whatever drive letter you are using. If you are also using a NAS, more information on why it’s the Q: drive and not the Z: drive coming later.
So, the Robocopy command to do all this;
robocopy “C:\Users\Craig\Documents\Lightroom Catalogs” “q:\Lightroom Cat Backup” /MIR /NP /S /V /LOG:”Q:\log\LRCatBackupLog.txt” /LEV:2 /R:10 /W:30
The first part in quotes is the location where the catalogues are stored, in other words, the source. The second part in quotes is the destination to copy the catalogues to, in other words, the destination
Now the command options;
/MIR means Mirror. This means that the destination will always be the same as the source. In simple terms it means that if a catalogue has changed, it will overwrite the one on the destination, if you delete a catalogue it will also delete the one on the destination. This helps keep space down, but does mean that it will delete the catalogue from the backup when you log off or shut down.
/NP this just stops the file progress being written to the log file
/S means include the subfolders, so this tells Robocopy to copy the entire structure, we don’t want to, so see the /LEV:2 command later
/V this is just for logging output so you can periodically check all is working as expected
/LOG: this creates a log file for the copy, the location to save it follows, you’ll see that I drop it in the same place as the destination for the copy
/LEV:2 this is important, this tells Robocopy to only include files and folders 2 levels deep. In other words, don’t include the preview files.
/R:10 just tells it to try 10 times if there is a failed copy, you can set this to what you like
/W:30 this just tells it to wait for 30 seconds between a failed copy, again, set this to what you like
If you want more information on Robocopy, visit https://technet.microsoft.com/en-us/library/cc733145.aspx
All that might be a bit overload, but if you’re not that interested in the workings, just use the command as shown above and change the source and destination locations to suit.
Ok, so we’ve got the command, but we need to get it to run when we log off or shut down (remember it doesn’t work in sleep or hibernate).
To do this we use a “Logoff Script” that runs everytime a user logs off.
Simply open notepad and put the Robocopy command in there and save it somewhere with the file extension .bat (I put it in My Documents and call it “Logoff Script.bat”). This has to be locally on the PC and not on a network drive/location as it won’t run when you log off otherwise.
Now, this next bit is only required if you have a NAS or other network storage, if you don’t skip down to SKIP TO HERE below
When you logoff, one of the first things your PC does is disconnect any network drives, therefore, your NAS drive mapping will not be available to Robocopy when it runs. Inside the logoff script I simply map the Q: drive to where I want to copy my catalogues to, run the Robocopy command and then disconnect this Q: drive again.
To do this you use the “net use” command to map and disconnect. You need to put a username and password for this connection in the square brackets. I have created a new user on my NAS just for this purpose, but can use an existing one, but remember the password is stored in the logoff script.
net use q: \\192.168.0.150\lrcatbackup /USER:[username] [password]
robocopy “C:\Users\Craig\Documents\Lightroom Catalogs” “q:\Lightroom Cat Backup” /MIR /S /V /LOG:”q:\log\LRCatBackupLog.txt” /LEV:2 /R:10 /W:30 net use q: /DELETE
robocopy “C:\Users\Craig\Documents\Lightroom Catalogs” “q:\Lightroom Cat Backup” /MIR /S /V /LOG:”q:\log\LRCatBackupLog.txt” /LEV:2 /R:10 /W:30
net use q: /DELETE
SKIP TO HERE
So, you either have a logoff script with 1 line or a logoff script with 3 lines depending on what you are using as the destination.
Now you need to tell Windows to run this logoff script when you logoff/shutdown.
To do this, you need to configure the logoff script inside the Local Group Policy Editor. Use the “Run” option or search in Windows 8 and 10 and type gpedit.msc to open the Local Group Policy Editor
We need to configure the Users Configuration Windows Settings, so click that option and you will see options displayed on the right
Select the “Scripts (Logon/Logoff) option (double click)
Double click the “Logoff” option to open the configuration for the Logoff Script
Click the “Add” button and then browse to the location you saved your logoff script, you don’t require anything in the “Script Parameters” box
Click “OK” and the script is added
Click “OK” again and that’s it, you can now close down the Local Group Policy Editor
Next time you log off or shut down your catalogues should be backed up. Depending on how many catalogues you have and how big they are, the first time you log off might take a while as it has to copy all of them. From then on in, it will only copy those that have changed (and delete those on the destination that have been deleted). Mine is so quick, I don’t see much of a delay (usually no more than a few seconds for big catalogues) on the shut down time.
As there is a log file created (as defined in the Robocopy command) you will be able to see that status of the last backup. This is what mine looks like (I’ve truncated it as it’s a lot of folders). You’ll notice that for some reason it shows a few files as “modified” even if they haven’t been, however, if you look at summary at the bottom, it still hasn’t copied them. In this example, I made a change in my “Alvor 2015” catalogue and you can see that this is flagged as “Newer” and is the only file that has been copied. If you compare the Started time at the top with the Ended time at the bottom, it took just 2 seconds to run.
You can now turn off the backups within Lightroom as they are not needed and you don’t need to be warned about it. To do this, within Lightroom select “Edit” and then “Catalog Settings” and change “Back up Catalog” to “Never”.
That’s it, you never need to worry about backing up your catalogues again. Just remember to occasionally check your backup log file once in a while to make sure the backups are working ok.
One thing that the Lightroom backup does is Optimize the Catalogue, so it’s a good idea to occasionally run this manually by selecting “Optimize Catalog” from the “File” menu but is only really required if you start to see things slowing down.
Please note! Lightroom Catalogues are priceless, please be careful when following these instructions. If in doubt make a full copy of them somewhere else before you start. All of the above is something I decided to do to make my life easier and is not an Adobe process. I cannot be held responsible for any loss of data that you may have from any of this information.