Documentation
¶
Index ¶
- Constants
- Variables
- type BackupMetadata
- type Client
- type MessagesServer
- func (s *MessagesServer) BackupSourceByReplicaset() (map[string]*Client, error)
- func (s *MessagesServer) BackupSourceNameByReplicaset() (map[string]string, error)
- func (s *MessagesServer) Clients() map[string]Client
- func (s *MessagesServer) ClientsByReplicaset() map[string][]Client
- func (s *MessagesServer) DBBackupFinished(ctx context.Context, msg *pb.DBBackupFinishStatus) (*pb.DBBackupFinishedAck, error)
- func (s *MessagesServer) IsShardedSystem() bool
- func (s *MessagesServer) LastBackupMetadata() *BackupMetadata
- func (s *MessagesServer) LastOplogTs() int64
- func (s *MessagesServer) ListBackups() (map[string]pb.BackupMetadata, error)
- func (s *MessagesServer) Logging(stream pb.Messages_LoggingServer) error
- func (s *MessagesServer) MessagesChat(stream pb.Messages_MessagesChatServer) error
- func (s *MessagesServer) OplogBackupFinished(ctx context.Context, msg *pb.OplogBackupFinishStatus) (*pb.OplogBackupFinishedAck, error)
- func (s *MessagesServer) RefreshClients() error
- func (s *MessagesServer) ReplicasetsRunningDBBackup() map[string]*Client
- func (s *MessagesServer) ReplicasetsRunningOplogBackup() map[string]*Client
- func (s *MessagesServer) ReplicasetsRunningRestore() map[string]*Client
- func (s *MessagesServer) RestoreBackUp(bm *pb.BackupMetadata, skipUsersAndRoles bool) error
- func (s *MessagesServer) RestoreBackupFromMetadataFile(filename string, skipUsersAndRoles bool) error
- func (s *MessagesServer) RestoreCompleted(ctx context.Context, msg *pb.RestoreComplete) (*pb.RestoreCompletedAck, error)
- func (s *MessagesServer) RestoreSourcesByReplicaset(bm *pb.BackupMetadata) (map[string]restoreSource, error)
- func (s *MessagesServer) StartBackup(opts *pb.StartBackup) error
- func (s *MessagesServer) StartBalancer() error
- func (s *MessagesServer) Stop()
- func (s *MessagesServer) StopBalancer() error
- func (s *MessagesServer) StopOplogTail() error
- func (s *MessagesServer) ValidateReplicasetAgents() error
- func (s *MessagesServer) WaitBackupFinish()
- func (s *MessagesServer) WaitOplogBackupFinish()
- func (s *MessagesServer) WaitRestoreFinish()
- func (s *MessagesServer) WorkDir() string
- func (s *MessagesServer) WriteBackupMetadata(filename string) error
Constants ¶
const ( EVENT_BACKUP_FINISH = iota EVENT_OPLOG_FINISH EVENT_RESTORE_FINISH )
Variables ¶
var ( ClientAlreadyExistsError = fmt.Errorf("Client ID already registered") UnknownClientID = fmt.Errorf("Unknown client ID") // This variable is exported because in tests we might want to change it Timeout = 10000 * time.Millisecond )
Functions ¶
This section is empty.
Types ¶
type BackupMetadata ¶
type BackupMetadata struct {
// contains filtered or unexported fields
}
func LoadMetadataFromFile ¶
func LoadMetadataFromFile(name string) (*BackupMetadata, error)
func NewBackupMetadata ¶
func NewBackupMetadata(opts *pb.StartBackup) *BackupMetadata
func (*BackupMetadata) AddReplicaset ¶
func (b *BackupMetadata) AddReplicaset(clusterID, replName, replUUID, dbBackupName, oplogBackupName string) error
AddReplicaset adds backup info for a replicaset using the replicaset name as the key
func (*BackupMetadata) Metadata ¶
func (b *BackupMetadata) Metadata() *pb.BackupMetadata
func (*BackupMetadata) RemoveReplicaset ¶
func (b *BackupMetadata) RemoveReplicaset(replName string) error
func (*BackupMetadata) WriteMetadataToFile ¶
func (b *BackupMetadata) WriteMetadataToFile(name string) error
WriteMetadataToFile writes the backup metadata to a file as JSON
type Client ¶
type Client struct {
ID string `json:"id"`
NodeType pb.NodeType `json:"node_type"`
NodeName string `json:"node_name"`
ClusterID string `json:"cluster_id"`
ReplicasetName string `json:"replicaset_name"`
ReplicasetUUID string `json:"replicaset_uuid"`
ReplicasetVersion int32 `json:"replicaset_version"`
LastCommandSent string `json:"last_command_sent"`
LastSeen time.Time `json:"last_seen"`
// contains filtered or unexported fields
}
func (*Client) CanRestoreBackup ¶
func (c *Client) CanRestoreBackup(backupType pb.BackupType, destinationType pb.DestinationType, bucket, name string) (pb.CanRestoreBackupResponse, error)
func (*Client) GetBackupSource ¶
type MessagesServer ¶
type MessagesServer struct {
// contains filtered or unexported fields
}
func NewMessagesServer ¶
func NewMessagesServer(workDir string, clientsRefreshSecs int, logger *logrus.Logger) *MessagesServer
func NewMessagesServerWithClientLogging ¶
func NewMessagesServerWithClientLogging(workDir string, clientsRefreshSecs int, logger *logrus.Logger) *MessagesServer
func (*MessagesServer) BackupSourceByReplicaset ¶
func (s *MessagesServer) BackupSourceByReplicaset() (map[string]*Client, error)
func (*MessagesServer) BackupSourceNameByReplicaset ¶
func (s *MessagesServer) BackupSourceNameByReplicaset() (map[string]string, error)
func (*MessagesServer) Clients ¶
func (s *MessagesServer) Clients() map[string]Client
func (*MessagesServer) ClientsByReplicaset ¶
func (s *MessagesServer) ClientsByReplicaset() map[string][]Client
func (*MessagesServer) DBBackupFinished ¶
func (s *MessagesServer) DBBackupFinished(ctx context.Context, msg *pb.DBBackupFinishStatus) (*pb.DBBackupFinishedAck, error)
DBBackupFinished process backup finished message from clients. After the mongodump call finishes, clients should call this method to inform the event to the server
func (*MessagesServer) IsShardedSystem ¶
func (s *MessagesServer) IsShardedSystem() bool
IsShardedSystem returns if a system is sharded. It check if the Node Type is: - Mongos - Config Server - Shard Server or if the ClusterID is not empty because in a sharded system, the cluster id is never empty.
func (*MessagesServer) LastBackupMetadata ¶
func (s *MessagesServer) LastBackupMetadata() *BackupMetadata
func (*MessagesServer) LastOplogTs ¶
func (s *MessagesServer) LastOplogTs() int64
func (*MessagesServer) ListBackups ¶
func (s *MessagesServer) ListBackups() (map[string]pb.BackupMetadata, error)
func (*MessagesServer) Logging ¶
func (s *MessagesServer) Logging(stream pb.Messages_LoggingServer) error
func (*MessagesServer) MessagesChat ¶
func (s *MessagesServer) MessagesChat(stream pb.Messages_MessagesChatServer) error
MessagesChat is the method exposed by gRPC to stream messages between the server and agents
func (*MessagesServer) OplogBackupFinished ¶
func (s *MessagesServer) OplogBackupFinished(ctx context.Context, msg *pb.OplogBackupFinishStatus) (*pb.OplogBackupFinishedAck, error)
OplogBackupFinished process oplog tailer finished message from clients. After the the oplog tailer has been closed on clients, clients should call this method to inform the event to the server
func (*MessagesServer) RefreshClients ¶
func (s *MessagesServer) RefreshClients() error
func (*MessagesServer) ReplicasetsRunningDBBackup ¶
func (s *MessagesServer) ReplicasetsRunningDBBackup() map[string]*Client
func (*MessagesServer) ReplicasetsRunningOplogBackup ¶
func (s *MessagesServer) ReplicasetsRunningOplogBackup() map[string]*Client
func (*MessagesServer) ReplicasetsRunningRestore ¶
func (s *MessagesServer) ReplicasetsRunningRestore() map[string]*Client
func (*MessagesServer) RestoreBackUp ¶
func (s *MessagesServer) RestoreBackUp(bm *pb.BackupMetadata, skipUsersAndRoles bool) error
RestoreBackUp will run a restore on each client, using the provided backup metadata to choose the source for each replicaset.
func (*MessagesServer) RestoreBackupFromMetadataFile ¶
func (s *MessagesServer) RestoreBackupFromMetadataFile(filename string, skipUsersAndRoles bool) error
RestoreBackupFromMetadataFile is just a wrappwe around RestoreBackUp that receives a metadata filename loads and parse it and then call RestoreBackUp
func (*MessagesServer) RestoreCompleted ¶
func (s *MessagesServer) RestoreCompleted(ctx context.Context, msg *pb.RestoreComplete) (*pb.RestoreCompletedAck, error)
RestoreCompleted handles a replicaset restore completed messages from clients. After restore is completed or upon errors, each client running the restore will cann this gRPC method to inform the server about the restore status.
func (*MessagesServer) RestoreSourcesByReplicaset ¶
func (s *MessagesServer) RestoreSourcesByReplicaset(bm *pb.BackupMetadata) (map[string]restoreSource, error)
func (*MessagesServer) StartBackup ¶
func (s *MessagesServer) StartBackup(opts *pb.StartBackup) error
TODO Create an API StartBackup message instead of using pb.StartBackup For example, we don't need DBBackupName & OplogBackupName and having them, here if we use pb.StartBackup message, leads to confusions
func (*MessagesServer) StartBalancer ¶
func (s *MessagesServer) StartBalancer() error
StartBalancer restarts the balancer if this is a sharded system
func (*MessagesServer) Stop ¶
func (s *MessagesServer) Stop()
func (*MessagesServer) StopBalancer ¶
func (s *MessagesServer) StopBalancer() error
StopBalancer stops the balancer if this is a sharded system
func (*MessagesServer) StopOplogTail ¶
func (s *MessagesServer) StopOplogTail() error
StopOplogTail calls every agent StopOplogTail(ts) method using the last oplog timestamp reported by the clients when they call DBBackupFinished after mongodump finish on each client. That way s.lastOplogTs has the last timestamp of the slowest backup
func (*MessagesServer) ValidateReplicasetAgents ¶
func (s *MessagesServer) ValidateReplicasetAgents() error
validateReplicasetAgents will run getShardMap and parse the results on a config server. With that list, we can validate if we have at least one agent connected to each replicaset. Currently it is mandatory to have one agent ON EACH cluster member. Maybe in the future we can relax the requirements because having one agent per replicaset might be enough but it needs more testing.
func (*MessagesServer) WaitBackupFinish ¶
func (s *MessagesServer) WaitBackupFinish()
func (*MessagesServer) WaitOplogBackupFinish ¶
func (s *MessagesServer) WaitOplogBackupFinish()
func (*MessagesServer) WaitRestoreFinish ¶
func (s *MessagesServer) WaitRestoreFinish()
func (*MessagesServer) WorkDir ¶
func (s *MessagesServer) WorkDir() string
WorkDir returns the server working directory.
func (*MessagesServer) WriteBackupMetadata ¶
func (s *MessagesServer) WriteBackupMetadata(filename string) error