-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
WIP: Add backup & restore commands #26944
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
Conversation
Sounds interesting, this could enable easy migration between databases. |
Testfixture itself support the backup/restore command. Maybe we can reuse those commands? # load
testfixtures -d postgres -c "postgres://user:password@localhost/database" -D testdata/fixtures
# dump
testfixtures --dump -d postgres -c "postgres://user:password@localhost/database" -D testdata/fixtures ref(https://github.com/go-testfixtures/testfixtures/blob/master/cmd/testfixtures/testfixtures.go) |
Is it the right way to use yaml like this? Suppose the user have a large database (I know some users have a >1G action table), would the large yaml files be unmarshaled into memory and cause problems? |
start := 0 | ||
|
||
for { | ||
objs, err := e.Table(table.Name).Limit(bufferSize, start).QueryInterface() |
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.
@wxiaoguang I don't think we read all records from database to memory. Take a look at this, only 100 records every time. For restoring, testfixture will read the whole yaml content into memory when generating SQL files. That maybe consumes much memories.
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.
For restoring, testfixture will read the whole yaml content into memory when generating SQL files. That maybe consumes much memories.
I meant this
Close as I'm not sure if it's a good idea for a big instance. Maybe improve the current SQL based implementation is better. |
This is a new method to backup database into a fixture-like yml files and then restoring to other databases become more easier.
How to backup a database into a fixture directory? Run
This will generate yml files per Gitea's database tables. One table one yaml file.
How to restore a directory with these fixtures files into a database? Run
ToDo List: