Commit Graph

139 Commits

Author SHA1 Message Date
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 2ad93c114e archive: add appConfig, icon and appStoreIcon 2024-12-09 23:25:31 +01:00
Girish Ramakrishnan cc759a8427 Add waiting for lock message 2024-12-09 08:40:54 +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
Girish Ramakrishnan 6407d795ed du: better error handling of du
du can fail when files and directories go missing. luckily, when du fails,
it still provides the best effort output
2024-11-06 14:54:52 +01:00
Girish Ramakrishnan 6c3ca9c364 shell: rework code to use shell.spawn
spawn gives out streams and we have more control over the stdout/stderr
buffers. otherwise, we have to provide a max buffer capture size to exec
2024-10-15 12:13:46 +02:00
Girish Ramakrishnan a9e1d7641d shell: make require take a tag 2024-10-14 21:08:32 +02:00
Girish Ramakrishnan 7f141605fa log the backuptask crash reason 2024-10-14 18:26:01 +02:00
Girish Ramakrishnan 6361737cf4 sudo: use debug() to have provide timestamped logs
the exception is when sudo calls backupupload.js which already has timestamped
output because it uses node

an alternative idea is to maybe not use this flag at all and always parse the output.
this is a bit complicated since we have to look for a timestamp in a stream.
2024-10-14 15:38:55 +02:00
Girish Ramakrishnan 6742cdf373 backups: remount remote if not mounted before a backup 2024-09-09 18:15:49 +02:00
Girish Ramakrishnan ea72cef7f9 storage: remove getProviderStatus 2024-09-09 17:36:51 +02:00
Girish Ramakrishnan 30633e7820 lint 2024-07-08 10:47:07 +02:00
Girish Ramakrishnan acfc67ed0a backuptask: typo in usage of getAvailableSize 2024-07-08 10:46:28 +02:00
Girish Ramakrishnan a6f078330f shell: no need to promise scoping 2024-02-21 19:40:27 +01:00
Girish Ramakrishnan cfd5c0f82b shell: rewrite exec to use execFile
this also renames execFile to execArgs
2024-02-21 18:54:43 +01:00
Girish Ramakrishnan 14c9260ab0 shell: exec encoding is utf8 by default and no shell
explicitly mark calls that require the shell
2024-02-21 17:47:25 +01:00
Girish Ramakrishnan 9b94cf18d0 convert more execSync to async 2024-02-21 11:00:12 +01:00
Girish Ramakrishnan 307a3ee015 apps: rename the config functions 2024-02-10 11:53:25 +01:00
Girish Ramakrishnan c69cf4731a remove extra space 2023-10-31 21:51:46 +01:00
Girish Ramakrishnan 47d7536e24 du: add dovecot index log to the exclude list 2023-10-17 10:00:27 +02:00
Girish Ramakrishnan dd9db22e9c Fix transient du error
du error: Command failed: du -Dsb "/home/yellowtent/boxdata/mail" du: cannot access '/home/yellowtent/boxdata/mail/vmail/user@example.com/mail/dovecot-uidlist.lock': No such file or directory .
2023-10-13 15:52:36 +05:30
Girish Ramakrishnan eee49a8291 move dashboard setting into dashboard.js 2023-08-11 21:04:10 +05:30
Girish Ramakrishnan e73b75e4b5 settings: move backup settings 2023-08-04 11:54:12 +05:30
Girish Ramakrishnan 050a82039a getBackupProviderStatus -> getProviderStatus 2023-07-15 11:00:45 +05:30
Girish Ramakrishnan c86059e070 backups: move limits into a sub object
fixes #817
2023-07-13 12:17:57 +05:30
Johannes Zellner 58a0b3d8e7 Ensure localPath is quoted in case it contains spaces 2023-05-21 14:14:42 +02:00
Girish Ramakrishnan af7a5d2182 updater: better error message 2023-01-30 12:54:25 +01:00
Girish Ramakrishnan 40bcfdba76 s3: throw any copy errors 2023-01-17 11:00:03 +01:00
Girish Ramakrishnan 8a5d4e2fb0 better debugs 2022-11-05 08:43:02 +01:00
Girish Ramakrishnan c3793da5bb split checkPrecondition so it can be used in cleaner as well 2022-10-02 17:41:21 +02:00
Girish Ramakrishnan 9d17c6606b rename to checkBackupPreconditions
since this is called only by the backup logic
2022-10-02 16:20:14 +02:00
Johannes Zellner 3c92971665 If backup storage precondition is not met we want to throw 2022-08-29 22:54:23 +02:00
Girish Ramakrishnan dddc5a1994 migrate app dataDir to volumes 2022-06-02 16:29:01 -07:00
Girish Ramakrishnan 6e98f5f36c backuptask: make upload/download async 2022-04-30 16:42:14 -07:00
Girish Ramakrishnan ea01586b52 storage: make copy async 2022-04-30 16:24:45 -07:00
Girish Ramakrishnan 8ef730ad9c backuptask: make upload/download async 2022-04-28 21:37:08 -07:00
Girish Ramakrishnan 7123ec433c split up backupformat logic into separate files 2022-04-28 19:10:57 -07:00
Girish Ramakrishnan c67d9fd082 move crypto code to hush.js 2022-04-28 18:12:17 -07:00
Girish Ramakrishnan 454f9c4a79 syncer: task processor cannot be async because of asyncjs quirk 2022-04-27 09:14:51 -07:00
Girish Ramakrishnan be458020dd use string interpolation 2022-04-26 18:55:02 -07:00
Girish Ramakrishnan 7f89dfd261 add once.js 2022-04-15 19:01:35 -05:00
Girish Ramakrishnan e878e71b20 promisify once 2022-04-15 17:59:41 -05:00
Girish Ramakrishnan 05d7a7f496 constness 2022-04-14 17:50:41 -05:00
Girish Ramakrishnan 685bda35b9 storage: make remove and removeDir async 2022-04-14 16:16:20 -05:00
Girish Ramakrishnan b51082f7e4 storage: checkPreconditions is now async 2022-04-14 07:40:19 -05:00
Girish Ramakrishnan 709d4041b2 backups: fix restore code path after backup id changes 2022-04-05 09:55:57 -07:00
Johannes Zellner b4b999bd74 Fix await safe usage 2022-04-05 13:17:49 +02:00
Girish Ramakrishnan ea3fd27123 backups: recursively update the dep preserveSecs
One idea was to compute this at cleanup time, but this has two problems:

* the UI won't reflect this value. can be good or bad
* the cleaner has no easy way to find out the "parent". I guess we should
  change our data structure, if we want to go down this route...
2022-04-04 21:29:35 -07:00
Girish Ramakrishnan 452a4d9a75 backups: add remotePath
the main motivation is that id can be used in REST API routes. previously,
the id was a path and this had a "/" in it. This made /api/v1/backups/:backupId
not work.
2022-04-04 20:40:40 -07:00
Girish Ramakrishnan aab6f222b3 better log 2022-02-28 11:04:44 -08:00