feat: multi bucket backup
This commit is contained in:
parent
6d4de4e677
commit
1899fa06e7
1 changed files with 21 additions and 18 deletions
|
|
@ -29,6 +29,9 @@ const MAIN_MINIO_SECRET_KEY = getEnvVar("MAIN_MINIO_SECRET_KEY");
|
|||
const MAIN_MINIO_BUCKET = getEnvVar("MAIN_MINIO_BUCKET");
|
||||
const BACKUP_MINIO_BUCKET = getEnvVar("BACKUP_MINIO_BUCKET");
|
||||
|
||||
const s3TargetUrl = `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`;
|
||||
const s3BackupUrl = `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`;
|
||||
|
||||
function jsonParseOrPlainText(str: string) {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
|
|
@ -51,7 +54,7 @@ export class BackupController extends Controller {
|
|||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
s3_backup_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_backup_endpoint: s3BackupUrl,
|
||||
s3_backup_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_backup_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_backup_bucket: BACKUP_MINIO_BUCKET,
|
||||
|
|
@ -133,16 +136,16 @@ export class BackupController extends Controller {
|
|||
body: JSON.stringify({
|
||||
backup_name: name,
|
||||
storage: {
|
||||
s3_source_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_source_endpoint: s3TargetUrl,
|
||||
s3_source_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_source_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_source_bucket: MAIN_MINIO_BUCKET,
|
||||
s3_dest_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_source_bucket: MAIN_MINIO_BUCKET.replaceAll(",", " "),
|
||||
s3_dest_endpoint: s3BackupUrl,
|
||||
s3_dest_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_dest_secret: MAIN_MINIO_SECRET_KEY,
|
||||
},
|
||||
database: {
|
||||
s3_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_endpoint: s3BackupUrl,
|
||||
s3_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_bucket: BACKUP_MINIO_BUCKET,
|
||||
|
|
@ -176,16 +179,16 @@ export class BackupController extends Controller {
|
|||
body: JSON.stringify({
|
||||
backup_name: body.name,
|
||||
storage: {
|
||||
s3_restore_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_restore_endpoint: s3TargetUrl,
|
||||
s3_restore_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_restore_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_restore_bucket: MAIN_MINIO_BUCKET,
|
||||
s3_backup_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_restore_bucket: MAIN_MINIO_BUCKET.replaceAll(",", " "),
|
||||
s3_backup_endpoint: s3BackupUrl,
|
||||
s3_backup_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_backup_secret: MAIN_MINIO_SECRET_KEY,
|
||||
},
|
||||
database: {
|
||||
s3_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_endpoint: s3BackupUrl,
|
||||
s3_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_bucket: BACKUP_MINIO_BUCKET,
|
||||
|
|
@ -211,7 +214,7 @@ export class BackupController extends Controller {
|
|||
},
|
||||
body: JSON.stringify({
|
||||
backup_name: body.name,
|
||||
s3_backup_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_backup_endpoint: s3BackupUrl,
|
||||
s3_backup_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_backup_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_backup_bucket: BACKUP_MINIO_BUCKET,
|
||||
|
|
@ -276,16 +279,16 @@ export class BackupController extends Controller {
|
|||
backup_name: body.name,
|
||||
prefix_timestamp: true,
|
||||
storage: {
|
||||
s3_source_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_source_endpoint: s3TargetUrl,
|
||||
s3_source_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_source_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_source_bucket: MAIN_MINIO_BUCKET,
|
||||
s3_dest_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_source_bucket: MAIN_MINIO_BUCKET.replaceAll(",", " "),
|
||||
s3_dest_endpoint: s3BackupUrl,
|
||||
s3_dest_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_dest_secret: MAIN_MINIO_SECRET_KEY,
|
||||
},
|
||||
database: {
|
||||
s3_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_endpoint: s3BackupUrl,
|
||||
s3_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_bucket: BACKUP_MINIO_BUCKET,
|
||||
|
|
@ -327,16 +330,16 @@ export class BackupController extends Controller {
|
|||
backup_name: body.name,
|
||||
prefix_timestamp: true,
|
||||
storage: {
|
||||
s3_source_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_source_endpoint: s3TargetUrl,
|
||||
s3_source_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_source_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_source_bucket: MAIN_MINIO_BUCKET,
|
||||
s3_dest_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_source_bucket: MAIN_MINIO_BUCKET.replaceAll(",", " "),
|
||||
s3_dest_endpoint: s3BackupUrl,
|
||||
s3_dest_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_dest_secret: MAIN_MINIO_SECRET_KEY,
|
||||
},
|
||||
database: {
|
||||
s3_endpoint: `${MAIN_MINIO_USE_SSL === "true" ? "https://" : "http://"}${MAIN_MINIO_HOST}${(MAIN_MINIO_PORT && ":" + MAIN_MINIO_PORT) || ""}`,
|
||||
s3_endpoint: s3BackupUrl,
|
||||
s3_access: MAIN_MINIO_ACCESS_KEY,
|
||||
s3_secret: MAIN_MINIO_SECRET_KEY,
|
||||
s3_bucket: BACKUP_MINIO_BUCKET,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue