mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
filer.backup: backup to local directory optionally is incremental
fixed one issue with https://github.com/chrislusf/seaweedfs/issues/2084
This commit is contained in:
parent
35ca9638c4
commit
dce1f02c9e
|
@ -377,12 +377,6 @@ directory = "/data"
|
||||||
# so each date directory contains all new and updated files.
|
# so each date directory contains all new and updated files.
|
||||||
is_incremental = false
|
is_incremental = false
|
||||||
|
|
||||||
[sink.local_incremental]
|
|
||||||
# all replicated files are under modified time as yyyy-mm-dd directories
|
|
||||||
# so each date directory contains all new and updated files.
|
|
||||||
enabled = false
|
|
||||||
directory = "/backup"
|
|
||||||
|
|
||||||
[sink.filer]
|
[sink.filer]
|
||||||
enabled = false
|
enabled = false
|
||||||
grpcAddress = "localhost:18888"
|
grpcAddress = "localhost:18888"
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
type LocalSink struct {
|
type LocalSink struct {
|
||||||
Dir string
|
Dir string
|
||||||
filerSource *source.FilerSource
|
filerSource *source.FilerSource
|
||||||
|
isIncremental bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -35,15 +36,17 @@ func (localsink *LocalSink) isMultiPartEntry(key string) bool {
|
||||||
return strings.HasSuffix(key, ".part") && strings.Contains(key, "/.uploads/")
|
return strings.HasSuffix(key, ".part") && strings.Contains(key, "/.uploads/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (localsink *LocalSink) initialize(dir string) error {
|
func (localsink *LocalSink) initialize(dir string, isIncremental bool) error {
|
||||||
localsink.Dir = dir
|
localsink.Dir = dir
|
||||||
|
localsink.isIncremental = isIncremental
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (localsink *LocalSink) Initialize(configuration util.Configuration, prefix string) error {
|
func (localsink *LocalSink) Initialize(configuration util.Configuration, prefix string) error {
|
||||||
dir := configuration.GetString(prefix + "directory")
|
dir := configuration.GetString(prefix + "directory")
|
||||||
|
isIncremental := configuration.GetBool(prefix + "is_incremental")
|
||||||
glog.V(4).Infof("sink.local.directory: %v", dir)
|
glog.V(4).Infof("sink.local.directory: %v", dir)
|
||||||
return localsink.initialize(dir)
|
return localsink.initialize(dir, isIncremental)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (localsink *LocalSink) GetSinkToDirectory() string {
|
func (localsink *LocalSink) GetSinkToDirectory() string {
|
||||||
|
@ -51,7 +54,7 @@ func (localsink *LocalSink) GetSinkToDirectory() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (localsink *LocalSink) IsIncremental() bool {
|
func (localsink *LocalSink) IsIncremental() bool {
|
||||||
return true
|
return localsink.isIncremental
|
||||||
}
|
}
|
||||||
|
|
||||||
func (localsink *LocalSink) DeleteEntry(key string, isDirectory, deleteIncludeChunks bool, signatures []int32) error {
|
func (localsink *LocalSink) DeleteEntry(key string, isDirectory, deleteIncludeChunks bool, signatures []int32) error {
|
||||||
|
|
|
@ -26,8 +26,6 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
||||||
viper.AddConfigPath("/usr/local/etc/seaweedfs/") // search path for bsd-style config directory in
|
viper.AddConfigPath("/usr/local/etc/seaweedfs/") // search path for bsd-style config directory in
|
||||||
viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
|
viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
|
||||||
|
|
||||||
glog.V(1).Infof("Reading %s.toml from %s", configFileName, viper.ConfigFileUsed())
|
|
||||||
|
|
||||||
if err := viper.MergeInConfig(); err != nil { // Handle errors reading the config file
|
if err := viper.MergeInConfig(); err != nil { // Handle errors reading the config file
|
||||||
if strings.Contains(err.Error(), "Not Found") {
|
if strings.Contains(err.Error(), "Not Found") {
|
||||||
glog.V(1).Infof("Reading %s: %v", viper.ConfigFileUsed(), err)
|
glog.V(1).Infof("Reading %s: %v", viper.ConfigFileUsed(), err)
|
||||||
|
@ -43,6 +41,7 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
glog.V(1).Infof("Reading %s.toml from %s", configFileName, viper.ConfigFileUsed())
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue