You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sonic/service/backup.go

37 lines
1.4 KiB
Go

2 years ago
package service
import (
"context"
"mime/multipart"
"github.com/go-sonic/sonic/model/dto"
)
type BackupService interface {
// GetBackup Get backup data by backup file name.
GetBackup(ctx context.Context, filename string, backupType BackupType) (*dto.BackupDTO, error)
// BackupWholeSite Zips work directory
2 years ago
BackupWholeSite(ctx context.Context, toBackupItems []string) (*dto.BackupDTO, error)
2 years ago
// ListFiles list all files under path
ListFiles(ctx context.Context, path string, backupType BackupType) ([]*dto.BackupDTO, error)
// GetBackupFilePath get filepath and check if the file exist
GetBackupFilePath(ctx context.Context, path string, filename string) (string, error)
// DeleteFile delete file
DeleteFile(ctx context.Context, path string, filename string) error
// ExportData export database data to json file
ExportData(ctx context.Context) (*dto.BackupDTO, error)
// ImportMarkdown import markdown file as post
ImportMarkdown(ctx context.Context, fileHeader *multipart.FileHeader) error
// ExportMarkdown export posts to markdown files
ExportMarkdown(ctx context.Context, needFrontMatter bool) (*dto.BackupDTO, error)
2 years ago
ListToBackupItems(ctx context.Context) ([]string, error)
2 years ago
}
type BackupType string
const (
WholeSite BackupType = "/api/admin/backups/work-dir"
2 years ago
JSONData BackupType = "/api/admin/backups/data"
2 years ago
Markdown BackupType = "/api/admin/backups/markdown/export"
)