Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make backups thread safe #213

Merged
merged 6 commits into from
Sep 2, 2020
Merged

Make backups thread safe #213

merged 6 commits into from
Sep 2, 2020

Conversation

lukechilds
Copy link
Member

This change removes the need for a lock file to prevent concurrent backups. Multiple backup threads can now run concurrently without issue.

This improves reliability, since int he edge case that a lock file doesn't get cleaned up correctly, no future backups would ever run.

mayankchhabra
mayankchhabra previously approved these changes Sep 2, 2020
Copy link
Member

@mayankchhabra mayankchhabra left a comment

Choose a reason for hiding this comment

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

Looks great, @lukechilds! Quick question — should we remove ${UMBREL_ROOT}/statuses/backup-in-progress via the next OTA update if it exists (just as a cleanup so everything's consistent with repo, even though it wouldn't make a difference)?

BACKUP_FOLDER="backup"
BACKUP_ROOT="${UMBREL_ROOT}/${BACKUP_FOLDER}"
BACKUP_FILE="${UMBREL_ROOT}/backup.tar.gz.pgp"
BACKUP_ROOT="${UMBREL_ROOT}/.backup/$RANDOM"
Copy link
Member

Choose a reason for hiding this comment

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

Wow, didn't know there was an always available $RANDOM in shell 😍

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not very random, in fact it's not even uniformly random, but yeah, it's always available in a shell and fine for stuff like this.

It's also not actually a variable but a function, so you can use it multiple times in the same line

e.g:

$ echo "${RANDOM}:${RANDOM}:${RANDOM}"
16448:13088:7550

@lukechilds
Copy link
Member Author

should we remove ${UMBREL_ROOT}/statuses/backup-in-progress via the next OTA update if it exists (just as a cleanup so everything's consistent with repo, even though it wouldn't make a difference)?

Good idea! I'll add a line to the update script.

@lukechilds
Copy link
Member Author

So it turns out the start script would've cleared the backup lock file anyway.

So I've removed all instances of cleaning up the lock file that were left in since we don't need them anymore, and added a single cleanup in the OTA update script.

@lukechilds lukechilds merged commit 514fad9 into getumbrel:master Sep 2, 2020
@lukechilds lukechilds mentioned this pull request Sep 2, 2020
lukechilds added a commit that referenced this pull request Sep 2, 2020
This update improves the reliability of automatic channel backups.

Changes:

- Increase decoy backup max interval to 12 hours (#214) a88541a
- Handle backup upload failure (#215) 9363d62
- Make backups thread safe (#213) 514fad9

Diff: v0.2.8...v0.2.7
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.

None yet

2 participants