Catalog Backup Files are Permanently Marked Temporary

  • 2
  • Problem
  • Updated 3 years ago
Merged

This conversation has been merged. Please reference the main conversation: Lightroom Classic: Backup 'extended attributes' prevent backup software working

At least on Windows 10, the catalog backups created by Lightroom are left permanently marked as "temporary" in the filesystem:

PS D:\Amazon Drive\Lightroom Catalogs> Get-ChildItem . -recurse | where {$_.attributes -match "temporary"} | ft fullname,lastwritetime,attributes -autosize
FullName                                                                                             LastWriteTime                 Attributes
--------                                                                                             -------------                 ----------
D:\Amazon Drive\Lightroom Catalogs\2017-03-03 2258\Lightroom Catalog.lrcat.zip                     3/3/2017 10:59:05 PM  Archive, Temporary
D:\Amazon Drive\Lightroom Catalogs\2017-03-04 1358\Lightroom Catalog.lrcat.zip                     3/4/2017 1:58:23 PM   Archive, Temporary
D:\Amazon Drive\Lightroom Catalogs\2017-03-04 1618\Lightroom Catalog.lrcat.zip                     3/4/2017 4:19:09 PM   Archive, Temporary
D:\Amazon Drive\Lightroom Catalogs\2017-03-17 1942\Lightroom-Catalog.zip                             3/17/2017 7:42:43 PM  Archive, Temporary
D:\Amazon Drive\Lightroom Catalogs\2017-03-18 1042\Lightroom Catalog.lrcat.zip                     3/18/2017 10:43:10 AM Archive, Temporary
While I'm not aware of any issue this causes for Lightroom itself, it does cause Amazon Drive to deem the file temporary (because it is) and skip the sync that would otherwise occur:
[2017-03-18 10:52:49.387 -05:00  Info] [FileFilter] ignoring temporary file 
"D:\Amazon Drive\Lightroom Catalogs\2017-03-18 1042\Lightroom Catalog.lrcat.zip"
The behavior exhibited by Amazon Drive is definitely reasonable, and is not exclusive to it. I'm sure plenty of backup services will ignore temporary files since a file marked this way should be temporary.

When Lightroom finishes its backup, it really should remove the "temporary" filesystem attribute since the file really isn't temporary anymore.
Photo of Myles Loffler

Myles Loffler

  • 6 Posts
  • 2 Reply Likes

Posted 3 years ago

  • 2
Photo of Assaf Frank

Assaf Frank

  • 148 Posts
  • 46 Reply Likes
I have exactly the same problem with livedrive And I have to manually unzip and zip again the files to create a new zip files without the temporary flag so my backup picks it up. Is there a way to remove the temporary flag with a command until it is fixed?
Photo of Myles Loffler

Myles Loffler

  • 6 Posts
  • 2 Reply Likes
Assaf,

I don't know of any way to unset the temporary attribute from the Windows GUI, but you can do it from the PowerShell. Here are two commands that should help you:

NOTE:
<top_level_path> is some path on your computer like D:\LightroomBackups that you want to assess and/or update.
List temporary Files
This command will show you all temporary files that exist in some directory structure. 
Get-ChildItem <top_level_path> -recurse | where {$_.attributes -match "temporary"} | ft fullname,lastwritetime,attributes -autosize

Remove Temporary Attribute
This command will unset the temporary attribute for the set of files listed by the previous command where the same <top_level_path> is used.
Get-ChildItem <top_level_path> -recurse | ForEach-Object -process {if (($_.attributes -band 0x100) -eq 0x100) {$_.attributes = ($_.attributes -band 0xFEFF)}}
WARNING:
This command assumes you want to remove the temporary attribute from every file that has it under an entire directory structure (i.e., every file in every directory under some parent directory).

If you would prefer to only update a single directory, remove the -recurse portion. If you would like to target exactly one file, use Get-Item <path_to_file> in place of Get-ChildItem <top_level_path> -recurse.

What's happening:
You may or may not care, but because I'd generally recommend against just running commands a stranger on the internet provides without understanding what's happening, here's an explanation of the most complex part of what is happening.

The file attributes are represented by a bitmask. The possible file attribute masks are listed on this page. To keep things succinct, your Lightroom catalogs will have an attribute mask represented in hexadecimal (essentially sets of 4 bits) as 0x120.

This comes from a bit-wise or of the two attributes which do apply:
  • 0x100 (hex) = 0001 0000 0000 (binary) = temporary
  • 0x20 (hex) = 0000 0010 0000 (binary) = archive
NOTE:
The calculator in Windows can convert these values for you if you select "Programmer" as the operation mode. You can also do it manually with relatively little learning.
A bit-wise or is a simple bit-by-by application of a logical or operator. An or operator works this way:
  • 1 or 1 = 1
  • 0 or 1 = 1
  • 1 or 0 = 1
  • 0 or 0 = 0
So we get to 0x120 by applying this rule to each column of bits:

    0001 0000 0000
0000 0010 0000
--------------
0001 0010 0000 binary --> 0x120 hex
We can tell which masks apply by using a bit-wise and against the mask. A mask applies if the mask itself is the output.

 A bit-wise and is just like an or, but the rules are slightly different:

  • 1 and 1 = 1
  • 0 and 1 = 0
  • 1 and 0 = 0
  • 0 and 0 = 0

So to isolate temporary files, we want to know where 0x100 applies:

    0001 0010 0000 (0x120 <-- Applies to Lightroom catalog backups)
    0001 0000 0000 (0x100 <-- Temporary file mask)
    --------------
    0001 0000 0000 (0x100 <-- The mask applies)
The -band argument in the commands above is what performs this bitwise-and operation. First it is used to isolate the files we want by performing the check above, and then it is used to clear the 0x100 mask:
    0000 0001 0010 0000 (0x0120 <-- Current mask)
    1111 1110 1111 1111 (0xFEFF <-- Unset 0x100)
    -------------------
    0000 0000 0010 0000 (0x0020 <-- New mask, no temporary attribute)
Hope this helps!

Myles

This conversation is no longer open for comments or replies.