Skip to content

Commit

Permalink
fix: backup should run in offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn-Huang-Tron committed Sep 25, 2023
1 parent fb5f97b commit 24469f2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/commands/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

cmds "github.com/bittorrent/go-btfs-cmds"
commands "github.com/bittorrent/go-btfs/commands"
"github.com/bittorrent/go-btfs/core/commands/cmdenv"
fsrepo "github.com/bittorrent/go-btfs/repo/fsrepo"
)

Expand All @@ -40,6 +41,14 @@ This command will create a backup of the data from the current BTFS node.
cmds.StringsOption(excludeOption, "exclude backup output file path"),
},
Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error {
nd, err := cmdenv.GetNode(env)
if err != nil {
return err
}

if nd.IsOnline {
return errors.New("this action must be run in offline mode, please stop your 'btfs daemon' first")
}
r, err := fsrepo.Open(env.(*commands.Context).ConfigRoot)
if err != nil {
return err
Expand Down

0 comments on commit 24469f2

Please sign in to comment.