mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(multi-server): add backups remote server
This commit is contained in:
@@ -5,9 +5,18 @@ import {
|
|||||||
apiRemoveBackup,
|
apiRemoveBackup,
|
||||||
apiUpdateBackup,
|
apiUpdateBackup,
|
||||||
} from "@/server/db/schema";
|
} from "@/server/db/schema";
|
||||||
import { runMariadbBackup } from "@/server/utils/backups/mariadb";
|
import {
|
||||||
import { runMongoBackup } from "@/server/utils/backups/mongo";
|
runMariadbBackup,
|
||||||
import { runMySqlBackup } from "@/server/utils/backups/mysql";
|
runRemoteMariadbBackup,
|
||||||
|
} from "@/server/utils/backups/mariadb";
|
||||||
|
import {
|
||||||
|
runMongoBackup,
|
||||||
|
runRemoteMongoBackup,
|
||||||
|
} from "@/server/utils/backups/mongo";
|
||||||
|
import {
|
||||||
|
runMySqlBackup,
|
||||||
|
runRemoteMySqlBackup,
|
||||||
|
} from "@/server/utils/backups/mysql";
|
||||||
import {
|
import {
|
||||||
runPostgresBackup,
|
runPostgresBackup,
|
||||||
runRemotePostgresBackup,
|
runRemotePostgresBackup,
|
||||||
@@ -116,7 +125,11 @@ export const backupRouter = createTRPCRouter({
|
|||||||
try {
|
try {
|
||||||
const backup = await findBackupById(input.backupId);
|
const backup = await findBackupById(input.backupId);
|
||||||
const mysql = await findMySqlByBackupId(backup.backupId);
|
const mysql = await findMySqlByBackupId(backup.backupId);
|
||||||
await runMySqlBackup(mysql, backup);
|
if (mysql.serverId) {
|
||||||
|
await runRemoteMySqlBackup(mysql, backup);
|
||||||
|
} else {
|
||||||
|
await runMySqlBackup(mysql, backup);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
@@ -132,7 +145,12 @@ export const backupRouter = createTRPCRouter({
|
|||||||
try {
|
try {
|
||||||
const backup = await findBackupById(input.backupId);
|
const backup = await findBackupById(input.backupId);
|
||||||
const mariadb = await findMariadbByBackupId(backup.backupId);
|
const mariadb = await findMariadbByBackupId(backup.backupId);
|
||||||
await runMariadbBackup(mariadb, backup);
|
|
||||||
|
if (mariadb.serverId) {
|
||||||
|
await runRemoteMariadbBackup(mariadb, backup);
|
||||||
|
} else {
|
||||||
|
await runMariadbBackup(mariadb, backup);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
@@ -148,7 +166,12 @@ export const backupRouter = createTRPCRouter({
|
|||||||
try {
|
try {
|
||||||
const backup = await findBackupById(input.backupId);
|
const backup = await findBackupById(input.backupId);
|
||||||
const mongo = await findMongoByBackupId(backup.backupId);
|
const mongo = await findMongoByBackupId(backup.backupId);
|
||||||
await runMongoBackup(mongo, backup);
|
|
||||||
|
if (mongo.serverId) {
|
||||||
|
await runRemoteMongoBackup(mongo, backup);
|
||||||
|
} else {
|
||||||
|
await runMongoBackup(mongo, backup);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ import path from "node:path";
|
|||||||
import type { BackupSchedule } from "@/server/api/services/backup";
|
import type { BackupSchedule } from "@/server/api/services/backup";
|
||||||
import type { Mariadb } from "@/server/api/services/mariadb";
|
import type { Mariadb } from "@/server/api/services/mariadb";
|
||||||
import { findProjectById } from "@/server/api/services/project";
|
import { findProjectById } from "@/server/api/services/project";
|
||||||
import { getServiceContainer } from "../docker/utils";
|
import {
|
||||||
|
getRemoteServiceContainer,
|
||||||
|
getServiceContainer,
|
||||||
|
} from "../docker/utils";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
import { uploadToS3 } from "./utils";
|
import { uploadToS3 } from "./utils";
|
||||||
|
|
||||||
export const runMariadbBackup = async (
|
export const runMariadbBackup = async (
|
||||||
@@ -56,3 +59,59 @@ export const runMariadbBackup = async (
|
|||||||
await unlink(hostPath);
|
await unlink(hostPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const runRemoteMariadbBackup = async (
|
||||||
|
mariadb: Mariadb,
|
||||||
|
backup: BackupSchedule,
|
||||||
|
) => {
|
||||||
|
const { appName, databasePassword, databaseUser, projectId, name, serverId } =
|
||||||
|
mariadb;
|
||||||
|
|
||||||
|
if (!serverId) {
|
||||||
|
throw new Error("Server ID not provided");
|
||||||
|
}
|
||||||
|
const project = await findProjectById(projectId);
|
||||||
|
const { prefix, database } = backup;
|
||||||
|
const destination = backup.destination;
|
||||||
|
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||||
|
const bucketDestination = path.join(prefix, backupFileName);
|
||||||
|
const { accessKey, secretAccessKey, bucket, region, endpoint } = destination;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { Id: containerId } = await getRemoteServiceContainer(
|
||||||
|
serverId,
|
||||||
|
appName,
|
||||||
|
);
|
||||||
|
const mariadbDumpCommand = `docker exec ${containerId} sh -c "mariadb-dump --user='${databaseUser}' --password='${databasePassword}' --databases ${database} | gzip"`;
|
||||||
|
const rcloneFlags = [
|
||||||
|
`--s3-access-key-id=${accessKey}`,
|
||||||
|
`--s3-secret-access-key=${secretAccessKey}`,
|
||||||
|
`--s3-region=${region}`,
|
||||||
|
`--s3-endpoint=${endpoint}`,
|
||||||
|
"--s3-no-check-bucket",
|
||||||
|
"--s3-force-path-style",
|
||||||
|
];
|
||||||
|
|
||||||
|
const rcloneDestination = `:s3:${bucket}/${bucketDestination}`;
|
||||||
|
const rcloneCommand = `rclone rcat ${rcloneFlags.join(" ")} "${rcloneDestination}"`;
|
||||||
|
|
||||||
|
await execAsyncRemote(serverId, `${mariadbDumpCommand} | ${rcloneCommand}`);
|
||||||
|
await sendDatabaseBackupNotifications({
|
||||||
|
applicationName: name,
|
||||||
|
projectName: project.name,
|
||||||
|
databaseType: "mariadb",
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
await sendDatabaseBackupNotifications({
|
||||||
|
applicationName: name,
|
||||||
|
projectName: project.name,
|
||||||
|
databaseType: "mariadb",
|
||||||
|
type: "error",
|
||||||
|
// @ts-ignore
|
||||||
|
errorMessage: error?.message || "Error message not provided",
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ import path from "node:path";
|
|||||||
import type { BackupSchedule } from "@/server/api/services/backup";
|
import type { BackupSchedule } from "@/server/api/services/backup";
|
||||||
import type { Mongo } from "@/server/api/services/mongo";
|
import type { Mongo } from "@/server/api/services/mongo";
|
||||||
import { findProjectById } from "@/server/api/services/project";
|
import { findProjectById } from "@/server/api/services/project";
|
||||||
import { getServiceContainer } from "../docker/utils";
|
import {
|
||||||
|
getRemoteServiceContainer,
|
||||||
|
getServiceContainer,
|
||||||
|
} from "../docker/utils";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
import { uploadToS3 } from "./utils";
|
import { uploadToS3 } from "./utils";
|
||||||
|
|
||||||
// mongodb://mongo:Bqh7AQl-PRbnBu@localhost:27017/?tls=false&directConnection=true
|
// mongodb://mongo:Bqh7AQl-PRbnBu@localhost:27017/?tls=false&directConnection=true
|
||||||
@@ -53,3 +56,59 @@ export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// mongorestore -d monguito -u mongo -p Bqh7AQl-PRbnBu --authenticationDatabase admin --gzip --archive=2024-04-13T05:03:58.937Z.dump.gz
|
// mongorestore -d monguito -u mongo -p Bqh7AQl-PRbnBu --authenticationDatabase admin --gzip --archive=2024-04-13T05:03:58.937Z.dump.gz
|
||||||
|
|
||||||
|
export const runRemoteMongoBackup = async (
|
||||||
|
mongo: Mongo,
|
||||||
|
backup: BackupSchedule,
|
||||||
|
) => {
|
||||||
|
const { appName, databasePassword, databaseUser, projectId, name, serverId } =
|
||||||
|
mongo;
|
||||||
|
|
||||||
|
if (!serverId) {
|
||||||
|
throw new Error("Server ID not provided");
|
||||||
|
}
|
||||||
|
const project = await findProjectById(projectId);
|
||||||
|
const { prefix, database } = backup;
|
||||||
|
const destination = backup.destination;
|
||||||
|
const backupFileName = `${new Date().toISOString()}.dump.gz`;
|
||||||
|
const bucketDestination = path.join(prefix, backupFileName);
|
||||||
|
const { accessKey, secretAccessKey, bucket, region, endpoint } = destination;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { Id: containerId } = await getRemoteServiceContainer(
|
||||||
|
serverId,
|
||||||
|
appName,
|
||||||
|
);
|
||||||
|
const mongoDumpCommand = `docker exec ${containerId} sh -c "mongodump -d '${database}' -u '${databaseUser}' -p '${databasePassword}' --authenticationDatabase=admin --gzip"`;
|
||||||
|
const rcloneFlags = [
|
||||||
|
`--s3-access-key-id=${accessKey}`,
|
||||||
|
`--s3-secret-access-key=${secretAccessKey}`,
|
||||||
|
`--s3-region=${region}`,
|
||||||
|
`--s3-endpoint=${endpoint}`,
|
||||||
|
"--s3-no-check-bucket",
|
||||||
|
"--s3-force-path-style",
|
||||||
|
];
|
||||||
|
|
||||||
|
const rcloneDestination = `:s3:${bucket}/${bucketDestination}`;
|
||||||
|
const rcloneCommand = `rclone rcat ${rcloneFlags.join(" ")} "${rcloneDestination}"`;
|
||||||
|
|
||||||
|
await execAsyncRemote(serverId, `${mongoDumpCommand} | ${rcloneCommand}`);
|
||||||
|
await sendDatabaseBackupNotifications({
|
||||||
|
applicationName: name,
|
||||||
|
projectName: project.name,
|
||||||
|
databaseType: "mongodb",
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
await sendDatabaseBackupNotifications({
|
||||||
|
applicationName: name,
|
||||||
|
projectName: project.name,
|
||||||
|
databaseType: "mongodb",
|
||||||
|
type: "error",
|
||||||
|
// @ts-ignore
|
||||||
|
errorMessage: error?.message || "Error message not provided",
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ import path from "node:path";
|
|||||||
import type { BackupSchedule } from "@/server/api/services/backup";
|
import type { BackupSchedule } from "@/server/api/services/backup";
|
||||||
import type { MySql } from "@/server/api/services/mysql";
|
import type { MySql } from "@/server/api/services/mysql";
|
||||||
import { findProjectById } from "@/server/api/services/project";
|
import { findProjectById } from "@/server/api/services/project";
|
||||||
import { getServiceContainer } from "../docker/utils";
|
import {
|
||||||
|
getRemoteServiceContainer,
|
||||||
|
getServiceContainer,
|
||||||
|
} from "../docker/utils";
|
||||||
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
import { sendDatabaseBackupNotifications } from "../notifications/database-backup";
|
||||||
import { execAsync } from "../process/execAsync";
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||||
import { uploadToS3 } from "./utils";
|
import { uploadToS3 } from "./utils";
|
||||||
|
|
||||||
export const runMySqlBackup = async (mysql: MySql, backup: BackupSchedule) => {
|
export const runMySqlBackup = async (mysql: MySql, backup: BackupSchedule) => {
|
||||||
@@ -53,3 +56,59 @@ export const runMySqlBackup = async (mysql: MySql, backup: BackupSchedule) => {
|
|||||||
await unlink(hostPath);
|
await unlink(hostPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const runRemoteMySqlBackup = async (
|
||||||
|
mysql: MySql,
|
||||||
|
backup: BackupSchedule,
|
||||||
|
) => {
|
||||||
|
const { appName, databaseRootPassword, projectId, name, serverId } = mysql;
|
||||||
|
|
||||||
|
if (!serverId) {
|
||||||
|
throw new Error("Server ID not provided");
|
||||||
|
}
|
||||||
|
const project = await findProjectById(projectId);
|
||||||
|
const { prefix, database } = backup;
|
||||||
|
const destination = backup.destination;
|
||||||
|
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||||
|
const bucketDestination = path.join(prefix, backupFileName);
|
||||||
|
const { accessKey, secretAccessKey, bucket, region, endpoint } = destination;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { Id: containerId } = await getRemoteServiceContainer(
|
||||||
|
serverId,
|
||||||
|
appName,
|
||||||
|
);
|
||||||
|
|
||||||
|
const mysqlDumpCommand = `docker exec ${containerId} sh -c "mysqldump --default-character-set=utf8mb4 -u 'root' --password='${databaseRootPassword}' --single-transaction --no-tablespaces --quick '${database}' | gzip"`;
|
||||||
|
const rcloneFlags = [
|
||||||
|
`--s3-access-key-id=${accessKey}`,
|
||||||
|
`--s3-secret-access-key=${secretAccessKey}`,
|
||||||
|
`--s3-region=${region}`,
|
||||||
|
`--s3-endpoint=${endpoint}`,
|
||||||
|
"--s3-no-check-bucket",
|
||||||
|
"--s3-force-path-style",
|
||||||
|
];
|
||||||
|
|
||||||
|
const rcloneDestination = `:s3:${bucket}/${bucketDestination}`;
|
||||||
|
const rcloneCommand = `rclone rcat ${rcloneFlags.join(" ")} "${rcloneDestination}"`;
|
||||||
|
|
||||||
|
await execAsyncRemote(serverId, `${mysqlDumpCommand} | ${rcloneCommand}`);
|
||||||
|
await sendDatabaseBackupNotifications({
|
||||||
|
applicationName: name,
|
||||||
|
projectName: project.name,
|
||||||
|
databaseType: "mysql",
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
await sendDatabaseBackupNotifications({
|
||||||
|
applicationName: name,
|
||||||
|
projectName: project.name,
|
||||||
|
databaseType: "mysql",
|
||||||
|
type: "error",
|
||||||
|
// @ts-ignore
|
||||||
|
errorMessage: error?.message || "Error message not provided",
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -65,50 +65,38 @@ export const runRemotePostgresBackup = async (
|
|||||||
postgres: Postgres,
|
postgres: Postgres,
|
||||||
backup: BackupSchedule,
|
backup: BackupSchedule,
|
||||||
) => {
|
) => {
|
||||||
const { appName, databaseUser, name, projectId } = postgres;
|
const { appName, databaseUser, name, projectId, serverId } = postgres;
|
||||||
|
|
||||||
|
if (!serverId) {
|
||||||
|
throw new Error("Server ID not provided");
|
||||||
|
}
|
||||||
const project = await findProjectById(projectId);
|
const project = await findProjectById(projectId);
|
||||||
|
|
||||||
const { prefix, database } = backup;
|
const { prefix, database } = backup;
|
||||||
const destination = backup.destination;
|
const destination = backup.destination;
|
||||||
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
const backupFileName = `${new Date().toISOString()}.sql.gz`;
|
||||||
const bucketDestination = path.join(prefix, backupFileName);
|
const bucketDestination = path.join(prefix, backupFileName);
|
||||||
const containerPath = `/backup/${backupFileName}`;
|
|
||||||
const hostPath = `./${backupFileName}`;
|
|
||||||
const { accessKey, secretAccessKey, bucket, region, endpoint } = destination;
|
const { accessKey, secretAccessKey, bucket, region, endpoint } = destination;
|
||||||
const rcloneDestination = `s3:${bucket}:${prefix}/${backupFileName}`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { Id: containerId } = await getRemoteServiceContainer(
|
const { Id: containerId } = await getRemoteServiceContainer(
|
||||||
postgres.serverId,
|
serverId,
|
||||||
appName,
|
appName,
|
||||||
);
|
);
|
||||||
const pgDumpCommand = `docker exec ${containerId} sh -c "pg_dump -Fc --no-acl --no-owner -h localhost -U ${databaseUser} --no-password '${database}' | gzip"`;
|
const pgDumpCommand = `docker exec ${containerId} sh -c "pg_dump -Fc --no-acl --no-owner -h localhost -U ${databaseUser} --no-password '${database}' | gzip"`;
|
||||||
// const rcloneConfig = `:s3,provider=Cloudflare,access_key_id=${accessKey},secret_access_key=${secretAccessKey},endpoint=${endpoint},acl=private,region=${region},bucket_name=${bucket},force_path_style=true`;
|
|
||||||
const rcloneFlags = [
|
const rcloneFlags = [
|
||||||
// `--s3-provider=Cloudflare`,
|
// `--s3-provider=Cloudflare`,
|
||||||
`--s3-access-key-id=${accessKey}`,
|
`--s3-access-key-id=${accessKey}`,
|
||||||
`--s3-secret-access-key=${secretAccessKey}`,
|
`--s3-secret-access-key=${secretAccessKey}`,
|
||||||
`--s3-region=${region}`,
|
`--s3-region=${region}`,
|
||||||
`--s3-endpoint=${endpoint}`, // Aquí puedes incluir 'https://'
|
`--s3-endpoint=${endpoint}`,
|
||||||
"--s3-no-check-bucket",
|
"--s3-no-check-bucket",
|
||||||
"--s3-force-path-style",
|
"--s3-force-path-style",
|
||||||
];
|
];
|
||||||
|
|
||||||
const rcloneDestination = `:s3:${bucket}/jinza/${backupFileName}`;
|
const rcloneDestination = `:s3:${bucket}/${bucketDestination}`;
|
||||||
const rcloneCommand = `rclone rcat ${rcloneFlags.join(" ")} "${rcloneDestination}"`;
|
const rcloneCommand = `rclone rcat ${rcloneFlags.join(" ")} "${rcloneDestination}"`;
|
||||||
|
|
||||||
// const pgDumpCommand = `pg_dump -Fc --no-acl --no-owner -h localhost -U ${databaseUser} --no-password '${database}' | gzip`;
|
|
||||||
// const rcloneCommand = `rclone rcat --s3-provider Other \
|
|
||||||
// --s3-access-key-id ${accessKey} \
|
|
||||||
// --s3-secret-access-key ${secretAccessKey} \
|
|
||||||
// --s3-region ${region} \
|
|
||||||
// --s3-endpoint ${endpoint} \
|
|
||||||
// --buffer-size 16M ${rcloneDestination}`;
|
|
||||||
// const rcloneCommand = `rclone rcat --buffer-size 16M ${rcloneDestination}`;
|
|
||||||
|
|
||||||
// const command = `
|
|
||||||
// // docker exec ${containerId} /bin/bash -c "${pgDumpCommand} | ${rcloneCommand}"
|
|
||||||
// `;
|
|
||||||
console.log(`${pgDumpCommand} | ${rcloneCommand}`);
|
console.log(`${pgDumpCommand} | ${rcloneCommand}`);
|
||||||
await execAsyncRemote(
|
await execAsyncRemote(
|
||||||
postgres.serverId,
|
postgres.serverId,
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import type { BackupSchedule } from "@/server/api/services/backup";
|
|||||||
import type { Destination } from "@/server/api/services/destination";
|
import type { Destination } from "@/server/api/services/destination";
|
||||||
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
||||||
import { scheduleJob, scheduledJobs } from "node-schedule";
|
import { scheduleJob, scheduledJobs } from "node-schedule";
|
||||||
import { runMariadbBackup } from "./mariadb";
|
import { runMariadbBackup, runRemoteMariadbBackup } from "./mariadb";
|
||||||
import { runMongoBackup } from "./mongo";
|
import { runMongoBackup, runRemoteMongoBackup } from "./mongo";
|
||||||
import { runMySqlBackup } from "./mysql";
|
import { runMySqlBackup, runRemoteMySqlBackup } from "./mysql";
|
||||||
import { runPostgresBackup, runRemotePostgresBackup } from "./postgres";
|
import { runPostgresBackup, runRemotePostgresBackup } from "./postgres";
|
||||||
|
|
||||||
export const uploadToS3 = async (
|
export const uploadToS3 = async (
|
||||||
@@ -17,9 +17,7 @@ export const uploadToS3 = async (
|
|||||||
|
|
||||||
const s3Client = new S3Client({
|
const s3Client = new S3Client({
|
||||||
region: region,
|
region: region,
|
||||||
...(endpoint && {
|
endpoint: endpoint,
|
||||||
endpoint: endpoint,
|
|
||||||
}),
|
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: accessKey,
|
accessKeyId: accessKey,
|
||||||
secretAccessKey: secretAccessKey,
|
secretAccessKey: secretAccessKey,
|
||||||
@@ -36,7 +34,6 @@ export const uploadToS3 = async (
|
|||||||
|
|
||||||
await s3Client.send(command);
|
await s3Client.send(command);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const scheduleBackup = (backup: BackupSchedule) => {
|
export const scheduleBackup = (backup: BackupSchedule) => {
|
||||||
const { schedule, backupId, databaseType, postgres, mysql, mongo, mariadb } =
|
const { schedule, backupId, databaseType, postgres, mysql, mongo, mariadb } =
|
||||||
backup;
|
backup;
|
||||||
@@ -48,11 +45,23 @@ export const scheduleBackup = (backup: BackupSchedule) => {
|
|||||||
await runPostgresBackup(postgres, backup);
|
await runPostgresBackup(postgres, backup);
|
||||||
}
|
}
|
||||||
} else if (databaseType === "mysql" && mysql) {
|
} else if (databaseType === "mysql" && mysql) {
|
||||||
await runMySqlBackup(mysql, backup);
|
if (mysql.serverId) {
|
||||||
|
await runRemoteMySqlBackup(mysql, backup);
|
||||||
|
} else {
|
||||||
|
await runMySqlBackup(mysql, backup);
|
||||||
|
}
|
||||||
} else if (databaseType === "mongo" && mongo) {
|
} else if (databaseType === "mongo" && mongo) {
|
||||||
await runMongoBackup(mongo, backup);
|
if (mongo.serverId) {
|
||||||
|
await runRemoteMongoBackup(mongo, backup);
|
||||||
|
} else {
|
||||||
|
await runMongoBackup(mongo, backup);
|
||||||
|
}
|
||||||
} else if (databaseType === "mariadb" && mariadb) {
|
} else if (databaseType === "mariadb" && mariadb) {
|
||||||
await runMariadbBackup(mariadb, backup);
|
if (mariadb.serverId) {
|
||||||
|
await runRemoteMariadbBackup(mariadb, backup);
|
||||||
|
} else {
|
||||||
|
await runMariadbBackup(mariadb, backup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user