CopyFile copies the entire database to file at the given path. A reader transaction is maintained during the copy so it is safe to continue using the database while a copy is in progress.
(path string, mode os.FileMode)
| 484 | // A reader transaction is maintained during the copy so it is safe to continue |
| 485 | // using the database while a copy is in progress. |
| 486 | func (tx *Tx) CopyFile(path string, mode os.FileMode) error { |
| 487 | f, err := tx.db.openFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode) |
| 488 | if err != nil { |
| 489 | return err |
| 490 | } |
| 491 | |
| 492 | _, err = tx.WriteTo(f) |
| 493 | if err != nil { |
| 494 | _ = f.Close() |
| 495 | return err |
| 496 | } |
| 497 | return f.Close() |
| 498 | } |
| 499 | |
| 500 | // allocate returns a contiguous block of memory starting at a given page. |
| 501 | func (tx *Tx) allocate(count int) (*common.Page, error) { |