Closed Bug 1885372 Opened 8 months ago Closed 8 months ago

Implement a basic `createBackup` method on BackupService

Categories

(Firefox :: Profile Backup, task, P1)

task

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: mconley, Assigned: mconley)

References

Details

(Whiteboard: [fidefe-device-migration] )

Attachments

(1 file)

For now, this can be fairly simple. The steps are roughly as follows:

  1. We will add a backup method to the abstract BackupResource class defined as such:
/**
 * @typedef {Object} ManifestEntry
 * A ManifestEntry is created by a BackupResource to describe the items
 * that have been backed up. The ManifestEntry is then serialized and written
 * to the backup manifest.
 */

  /**
   * Perform a safe copy of the resource(s) and write them into the backup
   * database.
   *
   * @param {string} stagingPath
   *   The path to the staging folder where copies of the datastores for this
   *   BackupResource should be written to.
   * @param {string} [profilePath=null]
   *   This is null if the backup is being run on the currently running user
   *   profile. If, however, the backup is being run on a different user profile
   *   (for example, it's being run from a BackgroundTask on a user profile that
   *   just shut down, or during test), then this is a string set to that user
   *   profile path.
   *
   * @returns {Promise<ManifestEntry>}
   */
  // eslint-disable-next-line no-unused-vars
  async backup(stagingPath, profilePath = null) {
    throw new Error("BackupResource::backup must be overridden");
  }

It is not expected that in this bug that backup should be implemented for each existing BackupResource subclass. That can come later.

  1. Add a new method createBackup on BackupService.
  2. Have createBackup check to see if a backups folder exists in the user profile directory. If not, create it.
  3. Check to see if a staging folder exists in the backups folder. If so, delete it.
  4. Create an empty staging folder in the backups folder.
  5. For each BackupResource, create a new directory under staging with the key from the resource class.
  6. Call backup on each BackupResource, passing the path to the staging folder. Wrap this in a try/catch, and log any errors.

It is expected that calling createBackup should log an error for each BackupResource, since none of them will initially implement backup.

Blocks: 1885609
Blocks: 1885614
Blocks: 1885929
Blocks: 1885939
Blocks: 1885941
Blocks: 1885944
Assignee: nobody → mconley
Duplicate of this bug: 1886609
Priority: P3 → P1
Blocks: 1887752
Blocks: 1887765
Pushed by mconley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bc7ca80e302a Create a basic createBackup method on BackupService. r=backup-reviewers,fchasen
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: