replicate: use creation time for local incremental file sink

related to https://github.com/chrislusf/seaweedfs/pull/1762
This commit is contained in:
Chris Lu 2021-01-28 02:17:41 -08:00
parent 822f1ade9d
commit da08402ba2
4 changed files with 7 additions and 10 deletions

View file

@ -11,7 +11,6 @@ import (
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/b2sink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/b2sink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/filersink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/filersink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/gcssink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/gcssink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/localincrementalsink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/localsink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/localsink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/s3sink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/s3sink"
"github.com/chrislusf/seaweedfs/weed/replication/sub" "github.com/chrislusf/seaweedfs/weed/replication/sub"

View file

@ -354,11 +354,10 @@ directory = "/buckets"
[sink.local] [sink.local]
enabled = false enabled = false
directory = "/data" directory = "/data"
todays_date_format = "" # set this to 2006-02-01 for incremental backup
[sink.local_incremental] [sink.local_incremental]
# all replicated files are under creation time as yyyy-mm-dd directories
enabled = false enabled = false
# all replicated files are under modification time date directory tree
directory = "/backup" directory = "/backup"
[sink.filer] [sink.filer]

View file

@ -43,13 +43,13 @@ func (r *Replicator) Replicate(ctx context.Context, key string, message *filer_p
} }
var dateKey string var dateKey string
if r.sink.GetName() == "local_incremental" { if r.sink.GetName() == "local_incremental" {
var mTime int64 var cTime int64
if message.NewEntry != nil { if message.NewEntry != nil {
mTime = message.NewEntry.Attributes.Mtime cTime = message.NewEntry.Attributes.Crtime
} else if message.OldEntry != nil { } else if message.OldEntry != nil {
mTime = message.OldEntry.Attributes.Mtime cTime = message.OldEntry.Attributes.Crtime
} }
dateKey = time.Unix(mTime, 0).Format("2006-01-02") dateKey = time.Unix(cTime, 0).Format("2006-01-02")
} }
newKey := util.Join(r.sink.GetSinkToDirectory(), dateKey, key[len(r.source.Dir):]) newKey := util.Join(r.sink.GetSinkToDirectory(), dateKey, key[len(r.source.Dir):])
glog.V(3).Infof("replicate %s => %s", key, newKey) glog.V(3).Infof("replicate %s => %s", key, newKey)

View file

@ -1,12 +1,11 @@
package localincrementalsink package localsink
import ( import (
"github.com/chrislusf/seaweedfs/weed/replication/sink" "github.com/chrislusf/seaweedfs/weed/replication/sink"
"github.com/chrislusf/seaweedfs/weed/replication/sink/localsink"
) )
type LocalIncSink struct { type LocalIncSink struct {
localsink.LocalSink LocalSink
} }
func (localincsink *LocalIncSink) GetName() string { func (localincsink *LocalIncSink) GetName() string {