Skip to content

Commit

Permalink
database backup
Browse files Browse the repository at this point in the history
  • Loading branch information
qishenonly committed Jan 23, 2024
1 parent d9c6d82 commit 15d6df8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions db/engine/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ByteStorage/FlyDB/config"
data2 "github.com/ByteStorage/FlyDB/db/data"
"github.com/ByteStorage/FlyDB/db/index"
"github.com/ByteStorage/FlyDB/lib/backup"
"github.com/ByteStorage/FlyDB/lib/const"
"go.uber.org/zap"
"io"
Expand Down Expand Up @@ -544,6 +545,15 @@ func (db *DB) loadIndexFromDataFiles() error {
return nil
}

// Backup the database to the specified directory
func (db *DB) Backup(dir string) error {
db.lock.RLock()
defer db.lock.RUnlock()

// Create a backup directory
return backup.CopyDir(db.options.DirPath, dir)
}

// Clean the DB data directory after the test is complete
func (db *DB) Clean() {
if db != nil {
Expand Down

0 comments on commit 15d6df8

Please sign in to comment.