polubis / 4markdown

11 stars 1 forks source link

[Feature] Add DB and storage backups #150

Open polubis opened 1 month ago

polubis commented 1 month ago

DoD

  1. Endpoint createBackup:

    • Allows the creation of backups for the database and storage files.
    • The backup is created in a separate bucket named projectId-backups.
    • Each backup has its own ID, which is a timestamp indicating when it was created.
    • Backups cannot be directly accessed via preview links to Firebase files.
    • A maximum of 4 backups are kept. When a new backup is created, the oldest one is removed.
    • Backups are created at weekly intervals.
    • The lifespan of each backup is 28 days (4 weeks).
  2. Endpoint useBackup:

    • Removes the current database and storage.
    • Applies storage files and database data from the specified backup.
    • Takes backupId, which is the ID of the backup (timestamp from when it was generated).
  3. Both endpoints require a specific token, which is a hash that must match the one defined in the environment during deployment.

  4. If no token is provided or if the token is invalid, an error is thrown.

  5. The backup structure stored in the backup bucket is as follows:

    [date-stamp]/
     ├── db/data.json
     └── storage/[storage structure taken from the source bucket]
polubis commented 1 month ago

TEsted