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

feat: added backup/restore #501

Merged
merged 3 commits into from
Sep 20, 2022
Merged

feat: added backup/restore #501

merged 3 commits into from
Sep 20, 2022

Conversation

chrisleekr
Copy link
Owner

Description

This PR is to support the backup/restore.

There are two main scripts:

  • scripts/backup.sh: It will use mongodump to archive all collections except trailing-trade-logs.
  • scripts/restore.sh: It will use mongorestore from the backup archive. Note that it will drop existing collections and replace them with the backup archive. After restoring success, it will flush the cache in Redis. Once it's done, it will kill the node to restart the container. Once the container is restarted, it will try to re-run the migration to make it up to date.

Related Issue

N/A

Motivation and Context

I will have a big migration and I will need to test multiple times. So backup/restore will be handy for testing.

How Has This Been Tested?

I tested on my end.

Screenshots (if appropriate):

image

image

@chrisleekr chrisleekr added the enhancement New feature or request label Sep 9, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #501 (c5d3601) into master (b8889e2) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #501   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           90        92    +2     
  Lines         3333      3385   +52     
  Branches       557       561    +4     
=========================================
+ Hits          3333      3385   +52     
Impacted Files Coverage Δ
app/frontend/webserver/handlers/backup-get.js 100.00% <100.00%> (ø)
app/frontend/webserver/handlers/index.js 100.00% <100.00%> (ø)
app/frontend/webserver/handlers/restore-post.js 100.00% <100.00%> (ø)
app/server-frontend.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@habibalkhabbaz
Copy link
Contributor

Wow @chrisleekr
It would be really useful feature!

@chrisleekr
Copy link
Owner Author

@habibalkhabbaz
Yeah, it would be. Since you are here, when you have time, would you mind reviewing/testing the code when you have time?

@habibalkhabbaz
Copy link
Contributor

@habibalkhabbaz

Yeah, it would be. Since you are here, when you have time, would you mind reviewing/testing the code when you have time?

Sure, gonna try it this evening based on my timezone (around 7 AM based on AEST).

Copy link
Contributor

@habibalkhabbaz habibalkhabbaz left a comment

Choose a reason for hiding this comment

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

It seems a cool update @chrisleekr 🚀
I only face a small issue since I have different values in my .env file.
Based on that, I added some comments.

scripts/backup.sh Outdated Show resolved Hide resolved
scripts/restore.sh Outdated Show resolved Hide resolved
@chrisleekr
Copy link
Owner Author

@habibalkhabbaz I've updated the code. Please review and let me know if you are happy with the fix. :)

@habibalkhabbaz
Copy link
Contributor

@habibalkhabbaz I've updated the code. Please review and let me know if you are happy with the fix. :)

Thanks for the update @chrisleekr
Sorry for the delay. I was upgrading my OS from Windows 10 to 11 and I face issues with my Docker.
My bot volume data was removed accidentally and I started to set up my bot again 😆

Anyway, I tried to back up and restore my DB with the latest update and it is working like a charm even if I have different values in the .env file

@chrisleekr
Copy link
Owner Author

:yay: Thanks @habibalkhabbaz

@chrisleekr chrisleekr merged commit 50eb2b8 into master Sep 20, 2022
@chrisleekr chrisleekr deleted the feat/db-backup-restore branch September 20, 2022 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants