Commit Graph

482 Commits

Author SHA1 Message Date
Girish Ramakrishnan 2e16dd983f backups: stash the stats to the backups table 2025-08-12 20:21:54 +05:30
Girish Ramakrishnan 47fc9561ab backups (tgz): save integrity information
we generate a signing key pair for each target. Initially, I had this
as global. We needed a route to return the public key and putting it
under backup target seemed natural. Since we delete the backups when
we delete a target, we lose all the signing hashes. So, it's fine to lose
the key pair on target delete.
2025-08-12 19:00:29 +05:30
Girish Ramakrishnan f8d74bbb6d backuptarget: add default at provisioning time (again)
we clear the db in the tests. the tests run the setup again and again.
so, it's easier to add default values in provision time instead of
migration.
2025-08-06 11:11:11 +02:00
Girish Ramakrishnan c4ee21bdb0 Revert "provision: add default backup target after setup"
This reverts commit 1a0d1f7d79.

20171205124434-settings-default-backupConfig.js already adds the default
2025-08-05 13:41:26 +02:00
Girish Ramakrishnan 1a0d1f7d79 provision: add default backup target after setup 2025-08-04 14:33:12 +02:00
Girish Ramakrishnan 132132307f backuptarget: rename label to name 2025-08-04 14:28:37 +02:00
Girish Ramakrishnan 5c1147bfa4 backupTargets: id is not used in config 2025-08-04 09:49:06 +02:00
Girish Ramakrishnan 547d8ae113 filesystem: rename backupFolder to backupDir 2025-08-02 10:37:37 +02:00
Girish Ramakrishnan c935744f4c backups: root ~~canal~~ path surgery
remove rootPath and getBackupFilePath from the backup target and
make this backend specific.
2025-08-02 10:15:34 +02:00
Girish Ramakrishnan ff6cbf6628 backups: encode extension into the remotePath 2025-08-01 20:42:12 +02:00
Girish Ramakrishnan 53e9925880 backups: make id, provider a backend specific setting
the backend can stash whatever values it wants in the config.
just like the DNS backends, we make verifyConfig return a sanitized config.
added benefit is that extra user fields (via API) are also not dumped into the db.
2025-08-01 18:55:04 +02:00
Girish Ramakrishnan ae3a34287a backup target: create snapshot and cache files per target
snapshot file tracks the snapshot directory. when app gets deleted,
the cleaner will remove the upstream snapshot directory when it runs.

cache files are used in rsync logic to track what was uploading into
snapshot in the previous run without needing to rescan upstream.
2025-07-30 11:44:42 +02:00
Girish Ramakrishnan cbc73f5c9a remove uuid module
built into node.js now
2025-07-28 12:54:09 +02:00
Girish Ramakrishnan 3f07bb5c3a backup targets: add test for all routes 2025-07-25 11:29:00 +02:00
Girish Ramakrishnan 94dd1eb0c2 backups: add setPrimary route 2025-07-25 09:43:26 +02:00
Girish Ramakrishnan 69cd766f88 backups: run cron schedule per target 2025-07-25 08:36:09 +02:00
Girish Ramakrishnan cfce39c1de backups: no need to track taskId, we track it in task.type+prefix 2025-07-25 07:41:48 +02:00
Girish Ramakrishnan 3aafbd2ccb backups: add backup multiple targets 2025-07-25 01:30:27 +02:00
Girish Ramakrishnan 931311f11f rename backups to backuptargets 2025-07-24 18:54:10 +02:00
Girish Ramakrishnan bf315258c5 backups: add target foreign key to backups table
format is part of the backup target

in the future, if we want per-app format or schedule, we can add this
separately to the apps table itself. the full box backup can ignore
apps with a set backup target and use the latest backup (like an errored app).
the nice thing is restore will work correctly.
2025-07-24 17:32:16 +02:00
Girish Ramakrishnan 9780db6fa0 add backup targets table 2025-07-24 17:32:16 +02:00
Girish Ramakrishnan 47580c6976 tasks: make type field longer 2025-07-18 14:24:24 +02:00
Girish Ramakrishnan b42be9899e tasks: add completed flag
in some cases, the tasks are setting percent to 100 and crashing later
2025-07-16 15:40:46 +02:00
Girish Ramakrishnan 3dcc9ad844 print the region 2025-07-16 09:15:05 +02:00
Girish Ramakrishnan 5548ed1b57 s3: fix malformed endpoint URL from older versions
this is specifically for linode, but may apply for other storages too
2025-07-16 09:12:57 +02:00
Girish Ramakrishnan 622aecfd6d users: add unset route for avatar
also add missing tests for avatar and profile locking
2025-07-15 10:06:26 +02:00
Girish Ramakrishnan bf8a5e6a11 oidc: separate clients for oidc and proxyAuth
in e2e, our test app has both. in such cases, the auth fails because
the redirect URI does not match
2025-07-13 15:51:39 +02:00
Girish Ramakrishnan 6ac0cd421a use the @cloudron/superagent module 2025-07-10 10:56:05 +02:00
Girish Ramakrishnan 19c9d7d59d updateInfo: move updateInfo into apps table
this has many advantages:
* easy to deliver the updateInfo via the apps object
* after updating, the task can clear it
* when apps are deleted, the info is automatically gone

otherwise, it's a mess of deps between apps/updater/apptask/rest routes

box update info is still in a file
2025-06-26 15:47:15 +02:00
Girish Ramakrishnan 6da8396c76 another schema update 2025-06-19 19:43:51 +02:00
Girish Ramakrishnan 79e0a1b94c Update schema 2025-06-19 18:10:11 +02:00
Girish Ramakrishnan b23699f0c1 db: change the encoding and collation
by mistake many fields are encoded at utf8 which is an alias of utf8mb3

fixes #836
2025-06-18 22:08:43 +02:00
Girish Ramakrishnan 4770b32287 tasks: add pending field
this indicates if a task is scheduled. previously, we relied
on task.progress being 1
2025-06-17 17:00:21 +02:00
Girish Ramakrishnan a93c85ebc9 profile: drop gravatar support
gravatar is owned by an external entity (Automattic) and we have an
unnecessary dep to this service. users can just upload a profile pic
2025-06-08 18:12:40 +02:00
Girish Ramakrishnan 827791574d typo 2025-05-07 16:10:39 +02:00
Girish Ramakrishnan 1bbdabc42f registry config: create table and migrate existing setting 2025-05-07 15:56:13 +02:00
Girish Ramakrishnan 7674e23580 Fix superagent use 2025-04-15 13:53:27 +02:00
Girish Ramakrishnan 5342dae5b3 tokens: add ip restriction 2025-03-07 17:50:50 +01:00
Girish Ramakrishnan 8e58349bfa replace with custom superagent based on fetch API 2025-02-15 15:14:09 +01:00
Girish Ramakrishnan dd5e4adc73 replace underscore with our own
we only need like 5 simple functions
2025-02-13 14:14:34 +01:00
Girish Ramakrishnan d0d0913c70 notifications: add context field 2024-12-11 22:29:00 +01:00
Girish Ramakrishnan 6004cd17bf notifications: per user email prefs 2024-12-11 19:12:20 +01:00
Girish Ramakrishnan 41bc08a07e backup: move appConfig to backups table
this is useful for clone also to copy notes, operators, checklist
of the time when the backup was made (as opposed to current)

at this point, it's not clear why we need a archives table. it's
an optimization to not have to store icon for every backup.
2024-12-10 21:04:37 +01:00
Girish Ramakrishnan 490840b71d archives: use separate table
Cleaner to separate things from the backups table.

* icon, appConfig, appStoreIcon etc are only valid for archives
* older version cloudron does not have appConfig in backups table (so it
  cannot be an archive entry)
2024-12-10 10:36:44 +01:00
Girish Ramakrishnan 2ad93c114e archive: add appConfig, icon and appStoreIcon 2024-12-09 23:25:31 +01:00
Girish Ramakrishnan cec2106cfe update the schema file 2024-12-09 22:42:22 +01:00
Girish Ramakrishnan 147e014205 backup: add archive flag 2024-12-09 16:25:31 +01:00
Girish Ramakrishnan 65a7f5f1c6 Use subarray instead of slice
says it's deprecated
2024-12-09 16:14:49 +01:00
Girish Ramakrishnan bb392207ea remove global lock
Currently, the update/apptask/fullbackup/platformstart take a
global lock and cannot run in parallel. This causes situations
where when a user tries to trigger an apptask, it says "waiting for
backup to finish..." etc

The solution is to let them run in parallel. We need a lock at the
app level as app operations running in parallel would be bad (tm).
In addition, the update task needs a lock just for the update part.
We also need multi-process locks. Running tasks as processes is core
to our "kill" strategy.

Various inter process locks were explored:

* node's IPC mechanism with process.send(). But this only works for direct node.js
children. taskworker is run via sudo and the IPC does not work.

* File lock using O_EXCL. Basic ideas to create lock files. While file creation
can be done atomically, it becomes complicated to clean up lock files when
the tasks crash. We need a way to know what locks were held by the crashing task.
flock and friends are not built-into node.js

* sqlite/redis were options but introduce additional deps

* Settled on MySQL based locking. Initial plan was to have row locks
or table locks. Each row is a kind of lock. While implementing, it was found that
we need many types of locks (and not just update lock and app locks). For example,
we need locks for each task type, so that only one task type is active at a time.

* Instead of rows, we can just lock table and have a json blob in it. This hit a road
block that LOCK TABLE is per session and our db layer cannot handle this easily! i.e
when issing two db.query() it might use two different connections from the pool. We have to
expose the connection, release connection etc.

* Next idea was atomic blob update of the blob checking if old blob was same. This approach,
was finally refined into a version field.

Phew!
2024-12-07 20:41:22 +01:00
Johannes Zellner 8493022f75 Allow apps to specify custom devices 2024-12-05 14:21:07 +01:00