Skip to content

Exclude application data directory from backups - #1660

Closed
somiljain2006 wants to merge 19 commits into
apple:mainfrom
somiljain2006:Container-Backup-Exclusion-fix
Closed

somiljain2006 wants to merge 19 commits into
apple:mainfrom
somiljain2006:Container-Backup-Exclusion-fix

Conversation

@somiljain2006

@somiljain2006 somiljain2006 commented Jun 7, 2026 •

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

[Why is this change needed?]

Fixes #1554

The application data directory (~/Library/Application Support/com.apple.container) can contain large, sparse files whose apparent size is significantly larger than their allocated size. This may cause backup tools to process unnecessary data or fail when backing up the container application data.

This change marks the application root directory with URLResourceKey.isExcludedFromBackupKey, preventing it from being included in backups while preserving normal container functionality.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

Automated Testing:

  • Added test coverage for backup exclusion behavior.
  • Verified all existing tests continue to pass.

Manual Verification:

  1. Built locally with make.
  2. Started the API server using ./bin/container system start.
  3. Verified ~/Library/Application Support/com.apple.container was created.
  4. Verified isExcludedFromBackupKey == true.
  5. Confirmed normal startup completed successfully.

@somiljain2006

somiljain2006 commented Jun 8, 2026 •

Copy link
Copy Markdown
Author

@jglogan @katiewasnothere @realrajaryan Can you review this pr?

@jglogan
jglogan requested a review from dkovba June 15, 2026 17:40
@somiljain2006
somiljain2006 force-pushed the Container-Backup-Exclusion-fix branch from c6b50c0 to 27af44b Compare June 15, 2026 22:46
@somiljain2006

Copy link
Copy Markdown
Author

@dkovba CI failure appears unrelated to this change.

@somiljain2006
somiljain2006 requested a review from dkovba June 16, 2026 06:25
@somiljain2006

Copy link
Copy Markdown
Author

@dkovba, I have addressed the changes. Can you review them

Comment thread Package.swift Resolved
@somiljain2006
somiljain2006 requested a review from dkovba June 16, 2026 22:57

@dkovba dkovba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution 👍

Comment thread Package.swift Resolved
@somiljain2006
somiljain2006 requested a review from dkovba June 17, 2026 22:44
@somiljain2006

Copy link
Copy Markdown
Author

@dkovba Can this be merged?

@dkovba dkovba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Please consider additional feedback.

@somiljain2006
somiljain2006 requested a review from dkovba August 29, 2026 08:55
@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Code Coverage

Tier Line Coverage
Unit 24.92%
Integration 66.65%
Combined 76.13%

@somiljain2006
somiljain2006 requested a review from dkovba August 30, 2026 05:02

@dkovba dkovba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users should be able to change which folders are excluded from backup, so we shouldn't overwrite that choice on every start. Set the exclusion only when a folder is first created.

@somiljain2006
somiljain2006 requested a review from dkovba September 3, 2026 04:59

do {
let appRootURL = URL(fileURLWithPath: appRoot.string)
try FileManager.default.createDirectory(at: appRootURL, withIntermediateDirectories: true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?

//===----------------------------------------------------------------------===//

import Foundation
import Logging

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we supposed to have a test here?


try FileManager.default.createDirectory(at: containerRoot, withIntermediateDirectories: true)

do {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this hasn't been addressed: #1660 (review)

@dkovba

dkovba commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Closed in favor of #2412.

@dkovba dkovba closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Exclude application data from backups via isExcludedFromBackupKey

2 participants