-
Notifications
You must be signed in to change notification settings - Fork 2
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: Implement backup and restore of dev-server database #488
Conversation
@@ -35,7 +40,7 @@ func (s Sqlite) GetDevProjectKeys(ctx context.Context) ([]string, error) { | |||
return keys, nil | |||
} | |||
|
|||
func (s Sqlite) GetDevProject(ctx context.Context, key string) (*model.Project, error) { | |||
func (s *Sqlite) GetDevProject(ctx context.Context, key string) (*model.Project, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converted to pointer so that s.database
can be updated after db restore
if err != nil { | ||
return "", errors.Wrap(err, "unable to close database before restoring backup") | ||
} | ||
err = os.Rename(filepath, s.dbPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conns []*sqllite.SQLiteConn | ||
} | ||
|
||
func NewManager(dbPath string, dbName string, backupFilePattern string, restoreFilePattern string) *Manager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a comment here to indicate the expected lifecycle of the managers. It looks like each one gets its own unique file name space so you could run multiple managers at the same time, but you also need to use care to not reuse the same one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done:
- The manager is safe to create multiple instances
- Each instance can only run 1 backup/restore at a time
Co-authored-by: Mike Zorn <[email protected]>
Co-authored-by: Mike Zorn <[email protected]>
return "", errors.Wrap(err, "open backup database") | ||
} | ||
|
||
defer func(sourceDb *sql.DB) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting stuff!
Requirements
Allows for exporting a backup and restoring a backup of the underlying sqlite3 database.
Downloading a backup db
Restoring a backup db
Related issues
Provide links to any issues in this repository or elsewhere relating to this pull request.
Describe the solution you've provided
Provide a clear and concise description of what you expect to happen.
Describe alternatives you've considered
Provide a clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the pull request here.