mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
feat: 升级应用增加备份选项 (#1750)
Refs https://github.com/1Panel-dev/1Panel/issues/1742
This commit is contained in:
parent
3b9f92e03f
commit
b05e5736a6
@ -58,6 +58,7 @@ type AppInstalledOperate struct {
|
||||
ForceDelete bool `json:"forceDelete"`
|
||||
DeleteBackup bool `json:"deleteBackup"`
|
||||
DeleteDB bool `json:"deleteDB"`
|
||||
Backup bool `json:"backup"`
|
||||
}
|
||||
|
||||
type AppInstalledUpdate struct {
|
||||
|
@ -236,7 +236,7 @@ func (a *AppInstallService) Operate(req request.AppInstalledOperate) error {
|
||||
case constant.Sync:
|
||||
return syncById(install.ID)
|
||||
case constant.Upgrade:
|
||||
return upgradeInstall(install.ID, req.DetailId)
|
||||
return upgradeInstall(install.ID, req.DetailId, req.Backup)
|
||||
default:
|
||||
return errors.New("operate not support")
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ func deleteLink(ctx context.Context, install *model.AppInstall, deleteDB bool, f
|
||||
return appInstallResourceRepo.DeleteBy(ctx, appInstallResourceRepo.WithAppInstallId(install.ID))
|
||||
}
|
||||
|
||||
func upgradeInstall(installId uint, detailId uint) error {
|
||||
func upgradeInstall(installId uint, detailId uint, backup bool) error {
|
||||
install, err := appInstallRepo.GetFirst(commonRepo.WithByID(installId))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -239,13 +239,14 @@ func upgradeInstall(installId uint, detailId uint) error {
|
||||
if install.Version == detail.Version {
|
||||
return errors.New("two version is same")
|
||||
}
|
||||
if err := NewIBackupService().AppBackup(dto.CommonBackup{Name: install.App.Key, DetailName: install.Name}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
install.Status = constant.Upgrading
|
||||
|
||||
go func() {
|
||||
if backup {
|
||||
if err = NewIBackupService().AppBackup(dto.CommonBackup{Name: install.App.Key, DetailName: install.Name}); err != nil {
|
||||
global.LOG.Errorf(i18n.GetMsgWithMap("ErrAppBackup", map[string]interface{}{"name": install.Name, "err": err.Error()}))
|
||||
}
|
||||
}
|
||||
var upErr error
|
||||
defer func() {
|
||||
if upErr != nil {
|
||||
|
@ -44,6 +44,7 @@ ErrNoSuchHost: "Network connection failed"
|
||||
ErrImagePullTimeOut: 'Image pull timeout'
|
||||
ErrContainerNotFound: '{{ .name }} container does not exist'
|
||||
ErrContainerMsg: '{{ .name }} container is abnormal, please check the log on the container page for details'
|
||||
ErrAppBackup: '{{ .name }} application backup failed err {{.err}}'
|
||||
|
||||
#file
|
||||
ErrFileCanNotRead: "File can not read"
|
||||
|
@ -44,6 +44,7 @@ ErrNoSuchHost: "網路連接失敗"
|
||||
ErrImagePullTimeOut: "鏡像拉取超時"
|
||||
ErrContainerNotFound: '{{ .name }} 容器不存在'
|
||||
ErrContainerMsg: '{{ .name }} 容器異常,具體請在容器頁面查看日誌'
|
||||
ErrAppBackup: '{{ .name }} 應用備份失敗 err {{.err}}'
|
||||
|
||||
#file
|
||||
ErrFileCanNotRead: "此文件不支持預覽"
|
||||
|
@ -44,6 +44,7 @@ ErrNoSuchHost: "网络连接失败"
|
||||
ErrImagePullTimeOut: '镜像拉取超时'
|
||||
ErrContainerNotFound: '{{ .name }} 容器不存在'
|
||||
ErrContainerMsg: '{{ .name }} 容器异常,具体请在容器页面查看日志'
|
||||
ErrAppBackup: '{{ .name }} 应用备份失败 err {{.err}}'
|
||||
|
||||
#file
|
||||
ErrFileCanNotRead: "此文件不支持预览"
|
||||
|
@ -1221,6 +1221,8 @@ const message = {
|
||||
cancelIgnore: 'Cancel ignore',
|
||||
ignoreList: 'ignore list',
|
||||
appHelper: 'Please view the installation instructions of some applications on the application details page',
|
||||
backupApp: 'Backup application before upgrade',
|
||||
backupAppHelper: 'If the upgrade fails, you can use the application backup to roll back',
|
||||
},
|
||||
website: {
|
||||
website: 'Website',
|
||||
|
@ -1166,6 +1166,8 @@ const message = {
|
||||
cancelIgnore: '取消忽略',
|
||||
ignoreList: '忽略列表',
|
||||
appHelper: '部分應用的安裝使用說明請在應用詳情頁查看',
|
||||
backupApp: '升級前備份應用',
|
||||
backupAppHelper: '升級失敗可以使用應用備份回滾',
|
||||
},
|
||||
website: {
|
||||
website: '網站',
|
||||
|
@ -1166,6 +1166,8 @@ const message = {
|
||||
cancelIgnore: '取消忽略',
|
||||
ignoreList: '忽略列表',
|
||||
appHelper: '部分应用的安装使用说明请在应用详情页查看',
|
||||
backupApp: '升级前备份应用',
|
||||
backupAppHelper: '升级失败可以使用应用备份回滚',
|
||||
},
|
||||
website: {
|
||||
website: '网站',
|
||||
|
@ -27,6 +27,10 @@
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="backup" v-if="operateReq.operate === 'upgrade'">
|
||||
<el-checkbox v-model="operateReq.backup" :label="$t('app.backupApp')" />
|
||||
<span class="input-help">{{ $t('app.backupAppHelper') }}</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -59,6 +63,7 @@ const operateReq = reactive({
|
||||
detailId: 0,
|
||||
operate: 'upgrade',
|
||||
installId: 0,
|
||||
backup: true,
|
||||
});
|
||||
const resourceName = ref('');
|
||||
const rules = ref<any>({
|
||||
|
Loading…
x
Reference in New Issue
Block a user