Skip to content

Commit

Permalink
filer.backup use replication.source.filer
Browse files Browse the repository at this point in the history
  • Loading branch information
zemul committed Nov 3, 2022
1 parent 54d815f commit 07bf6f9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions weed/command/filer_backup.go
Expand Up @@ -83,6 +83,11 @@ func doFilerBackup(grpcDialOption grpc.DialOption, backupOption *FilerBackupOpti
if dataSink == nil {
return fmt.Errorf("no data sink configured in replication.toml")
}
if config.GetBool("source.filer.enabled") {
*backupOption.filer = config.GetString("source.filer.address")
*backupOption.path = config.GetString("source.filer.directory")
*backupOption.excludePaths = config.GetString("source.filer.excludeDirectories")
}

sourceFiler := pb.ServerAddress(*backupOption.filer)
sourcePath := *backupOption.path
Expand Down
2 changes: 1 addition & 1 deletion weed/command/filer_replication.go
Expand Up @@ -59,7 +59,7 @@ func runFilerReplicate(cmd *Command, args []string) bool {

// avoid recursive replication
if config.GetBool("notification.source.filer.enabled") && config.GetBool("notification.sink.filer.enabled") {
if config.GetString("source.filer.grpcAddress") == config.GetString("sink.filer.grpcAddress") {
if config.GetString("source.filer.address") == config.GetString("sink.filer.address") {
fromDir := config.GetString("source.filer.directory")
toDir := config.GetString("sink.filer.directory")
if strings.HasPrefix(toDir, fromDir) {
Expand Down
4 changes: 2 additions & 2 deletions weed/command/scaffold/replication.toml
Expand Up @@ -8,7 +8,7 @@

[source.filer] # deprecated. Only useful with "weed filer.replicate"
enabled = true
grpcAddress = "localhost:18888"
address = "localhost:8888"
# all files under this directory tree are replicated.
# this is not a directory on your hard drive, but on your filer.
# i.e., all files with this "prefix" are sent to notification message queue.
Expand All @@ -25,7 +25,7 @@ is_incremental = false

[sink.filer]
enabled = false
grpcAddress = "localhost:18888"
address = "localhost:8888"
# all replicated files are under this directory tree
# this is not a directory on your hard drive, but on your filer.
# i.e., all received files will be "prefixed" to this directory.
Expand Down
5 changes: 3 additions & 2 deletions weed/replication/sink/filersink/filer_sink.go
Expand Up @@ -54,9 +54,10 @@ func (fs *FilerSink) IsIncremental() bool {
func (fs *FilerSink) Initialize(configuration util.Configuration, prefix string) error {
fs.isIncremental = configuration.GetBool(prefix + "is_incremental")
fs.dataCenter = configuration.GetString(prefix + "dataCenter")
filerAddress := pb.ServerAddress(configuration.GetString(prefix + "address"))
return fs.DoInitialize(
"",
configuration.GetString(prefix+"grpcAddress"),
filerAddress.ToHttpAddress(),
filerAddress.ToGrpcAddress(),
configuration.GetString(prefix+"directory"),
configuration.GetString(prefix+"replication"),
configuration.GetString(prefix+"collection"),
Expand Down
5 changes: 3 additions & 2 deletions weed/replication/source/filer_source.go
Expand Up @@ -32,9 +32,10 @@ type FilerSource struct {

func (fs *FilerSource) Initialize(configuration util.Configuration, prefix string) error {
fs.dataCenter = configuration.GetString(prefix + "dataCenter")
filerAddress := pb.ServerAddress(configuration.GetString(prefix + "address"))
return fs.DoInitialize(
"",
configuration.GetString(prefix+"grpcAddress"),
filerAddress.ToHttpAddress(),
filerAddress.ToGrpcAddress(),
configuration.GetString(prefix+"directory"),
false,
)
Expand Down

0 comments on commit 07bf6f9

Please sign in to comment.