mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-26 00:36:12 +08:00
parent
5db6e7eb68
commit
0ed1b1aceb
6 changed files with 33 additions and 13 deletions
|
|
@ -233,7 +233,7 @@ func (r *Local) Backup(info BackupInfo) error {
|
|||
func (r *Local) Recover(info RecoverInfo) error {
|
||||
fi, _ := os.Open(info.SourceFile)
|
||||
defer fi.Close()
|
||||
cmd := exec.Command("docker", "exec", "-i", r.ContainerName, "mysql", "-uroot", "-p"+r.Password, info.Name)
|
||||
cmd := exec.Command("docker", "exec", "-i", r.ContainerName, "mysql", "-uroot", "-p"+r.Password, "--default-character-set="+info.Format, info.Name)
|
||||
if strings.HasSuffix(info.SourceFile, ".gz") {
|
||||
gzipFile, err := os.Open(info.SourceFile)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
<DrawerHeader :header="$t('commons.button.import')" :resource="title" :back="handleClose" />
|
||||
</template>
|
||||
<div v-loading="loading">
|
||||
<div class="mb-4" v-if="type === 'mysql' || type === 'mariadb'">
|
||||
<el-alert type="error" :title="$t('database.formatHelper', [remark])" />
|
||||
</div>
|
||||
<el-upload ref="uploadRef" drag :on-change="fileOnChange" class="upload-demo" :auto-upload="false">
|
||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||
<div class="el-upload__text">
|
||||
|
|
@ -16,7 +19,7 @@
|
|||
v-if="isUpload"
|
||||
text-inside
|
||||
:stroke-width="12"
|
||||
:percentage="uploadPrecent"
|
||||
:percentage="uploadPercent"
|
||||
></el-progress>
|
||||
<div v-if="type === 'mysql'" style="width: 80%" class="el-upload__tip">
|
||||
<span class="input-help">{{ $t('database.supportUpType') }}</span>
|
||||
|
|
@ -93,7 +96,7 @@ import { MsgError, MsgSuccess } from '@/utils/message';
|
|||
|
||||
const loading = ref();
|
||||
const isUpload = ref();
|
||||
const uploadPrecent = ref<number>(0);
|
||||
const uploadPercent = ref<number>(0);
|
||||
const selects = ref<any>([]);
|
||||
const baseDir = ref();
|
||||
|
||||
|
|
@ -110,15 +113,18 @@ const upVisible = ref(false);
|
|||
const type = ref();
|
||||
const name = ref();
|
||||
const detailName = ref();
|
||||
const remark = ref();
|
||||
interface DialogProps {
|
||||
type: string;
|
||||
name: string;
|
||||
detailName: string;
|
||||
remark: string;
|
||||
}
|
||||
const acceptParams = async (params: DialogProps): Promise<void> => {
|
||||
type.value = params.type;
|
||||
name.value = params.name;
|
||||
detailName.value = params.detailName;
|
||||
remark.value = params.remark;
|
||||
|
||||
const pathRes = await loadBaseDir();
|
||||
if (type.value === 'mysql') {
|
||||
|
|
@ -156,15 +162,21 @@ const onRecover = async (row: File.File) => {
|
|||
detailName: detailName.value,
|
||||
file: baseDir.value + row.name,
|
||||
};
|
||||
loading.value = true;
|
||||
await handleRecoverByUpload(params)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
ElMessageBox.confirm(i18n.global.t('commons.msg.recoverHelper'), i18n.global.t('commons.button.recover'), {
|
||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||
type: 'info',
|
||||
}).then(async () => {
|
||||
loading.value = true;
|
||||
await handleRecoverByUpload(params)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const uploaderFiles = ref<UploadFiles>([]);
|
||||
|
|
@ -247,7 +259,7 @@ const submitUpload = async (file: any) => {
|
|||
const progress = Math.round(
|
||||
((uploadedChunkCount + progressEvent.loaded / progressEvent.total) * 100) / chunkCount,
|
||||
);
|
||||
uploadPrecent.value = progress;
|
||||
uploadPercent.value = progress;
|
||||
},
|
||||
});
|
||||
uploadedChunkCount++;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ const message = {
|
|||
confirmNoNull: 'Make sure the value {0} is not empty',
|
||||
errPort: 'Incorrect port information, please confirm!',
|
||||
remove: 'Remove',
|
||||
recoverHelper: 'The current data will be overwritten. Do you want to continue?',
|
||||
},
|
||||
login: {
|
||||
username: 'UserName',
|
||||
|
|
@ -383,6 +384,8 @@ const message = {
|
|||
version: 'DB version',
|
||||
userHelper: 'The root user or a database user with root privileges can access the remote database.',
|
||||
|
||||
formatHelper:
|
||||
'The current database character set is {0}, the character set inconsistency may cause recovery failure',
|
||||
selectFile: 'Select file',
|
||||
dropHelper: 'You can drag and drop the uploaded file here or',
|
||||
clickHelper: 'click to upload',
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ const message = {
|
|||
confirmNoNull: '請確認 {0} 值不為空',
|
||||
errPort: '錯誤的端口信息,請確認!',
|
||||
remove: '移出',
|
||||
recoverHelper: '當前數據將被覆蓋,是否繼續?',
|
||||
},
|
||||
login: {
|
||||
username: '用戶名',
|
||||
|
|
@ -374,6 +375,7 @@ const message = {
|
|||
version: '數據庫版本',
|
||||
userHelper: 'root 用戶或者擁有 root 權限的數據庫用戶',
|
||||
|
||||
formatHelper: '當前資料庫字符集為 {0},字符集不一致可能導致恢復失敗',
|
||||
selectFile: '選擇文件',
|
||||
dropHelper: '將上傳文件拖拽到此處,或者',
|
||||
clickHelper: '點擊上傳',
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ const message = {
|
|||
confirmNoNull: '请确认 {0} 值不为空',
|
||||
errPort: '错误的端口信息,请确认!',
|
||||
remove: '移出',
|
||||
recoverHelper: '当前数据将被覆盖,是否继续?',
|
||||
},
|
||||
login: {
|
||||
username: '用户名',
|
||||
|
|
@ -374,6 +375,7 @@ const message = {
|
|||
version: '数据库版本',
|
||||
userHelper: 'root 用户或者拥有 root 权限的数据库用户',
|
||||
|
||||
formatHelper: '当前数据库字符集为 {0},字符集不一致可能导致恢复失败',
|
||||
selectFile: '选择文件',
|
||||
dropHelper: '将上传文件拖拽到此处,或者',
|
||||
clickHelper: '点击上传',
|
||||
|
|
|
|||
|
|
@ -546,6 +546,7 @@ const buttons = [
|
|||
type: currentDB.value.type,
|
||||
name: currentDBName.value,
|
||||
detailName: row.name,
|
||||
remark: row.format,
|
||||
};
|
||||
uploadRef.value!.acceptParams(params);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue