[FEATURE] Backup Database sync
This commit is contained in:
parent
b538ab5089
commit
7d34fcfce8
7 changed files with 79 additions and 15 deletions
|
@ -16,16 +16,31 @@ function payloadFilter(req, res) {
|
|||
const serverSpec = req.body;
|
||||
if (!serverSpec) return res.sendStatus(400);
|
||||
const { name, host, version, serverType, memory } = serverSpec;
|
||||
const { backupHost, backupBucket, backupId, backupKey } = serverSpec;
|
||||
const { backupHost, backupBucket, backupId, backupKey, backupInterval } =
|
||||
serverSpec;
|
||||
if (!name) return res.status(400).send("Server name is required!");
|
||||
if (!host) return res.status(400).send("Server host is required!");
|
||||
if (!dnsRegex.test(host)) return res.status(400).send("Hostname invalid!");
|
||||
if (!version) return res.status(400).send("Server version is required!");
|
||||
if (!serverType) return res.status(400).send("Server type is required!");
|
||||
if (!memory) return res.status(400).send("Memory is required!");
|
||||
if (!!backupHost || !!backupBucket || !!backupId || !!backupKey) {
|
||||
if (
|
||||
!!backupHost ||
|
||||
!!backupBucket ||
|
||||
!!backupId ||
|
||||
!!backupKey ||
|
||||
!backupInterval
|
||||
) {
|
||||
// If any keys are required, all are required
|
||||
if (!(!!backupHost && !!backupBucket && !!backupId && !!backupKey))
|
||||
if (
|
||||
!(
|
||||
!!backupHost &&
|
||||
!!backupBucket &&
|
||||
!!backupId &&
|
||||
!!backupKey &&
|
||||
!!backupInterval
|
||||
)
|
||||
)
|
||||
return res.status(400).send("All backup keys are required!");
|
||||
if (!dnsRegex.test(backupHost))
|
||||
return res.status(400).send("Backup Host invalid!");
|
||||
|
|
|
@ -20,6 +20,7 @@ export async function createServerEntry(serverSpec) {
|
|||
backupBucket: backup_bucket_path,
|
||||
backupId: backup_id,
|
||||
backupKey: backup_key,
|
||||
backupInterval: backup_interval,
|
||||
} = serverSpec;
|
||||
var q = insertQuery(table, {
|
||||
name,
|
||||
|
@ -31,6 +32,7 @@ export async function createServerEntry(serverSpec) {
|
|||
backup_bucket_path,
|
||||
backup_id,
|
||||
backup_key,
|
||||
backup_interval,
|
||||
});
|
||||
q += "\n RETURNING *";
|
||||
try {
|
||||
|
@ -71,9 +73,28 @@ export async function getServerEntry(serverId) {
|
|||
version,
|
||||
server_type: serverType,
|
||||
memory,
|
||||
backup_host: backupHost,
|
||||
backup_bucket_path: backupPath,
|
||||
backup_id: backupId,
|
||||
backup_key: backupKey,
|
||||
backup_interval: backupInterval,
|
||||
} = serverSpecs[0];
|
||||
const mclName = getMclName(host, id);
|
||||
return { name, mclName, id, host, version, serverType, memory };
|
||||
return {
|
||||
name,
|
||||
mclName,
|
||||
id,
|
||||
host,
|
||||
version,
|
||||
serverType,
|
||||
memory,
|
||||
backupHost,
|
||||
backupPath,
|
||||
backupId,
|
||||
backupKey,
|
||||
backupInterval
|
||||
|
||||
};
|
||||
} catch (e) {
|
||||
asExpressClientError(e);
|
||||
}
|
||||
|
|
|
@ -33,20 +33,20 @@ env:
|
|||
- name: DEST_DIR
|
||||
value: /backups
|
||||
- name: LINK_LATEST
|
||||
value: "false"
|
||||
value: "true"
|
||||
- name: TAR_COMPRESS_METHOD
|
||||
value: gzip
|
||||
- name: ZSTD_PARAMETERS
|
||||
value: -3 --long=25 --single-thread
|
||||
- name: RCLONE_REMOTE
|
||||
value: mc-dunemask-net
|
||||
value: mcl-backup-changeme
|
||||
- name: RCLONE_DEST_DIR
|
||||
value: /minecraft-backups/deltasmp-backups
|
||||
value: /mcl/backups/changeme
|
||||
- name: RCLONE_COMPRESS_METHOD
|
||||
value: gzip
|
||||
image: itzg/mc-backup:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: mcs-deltasmp-minecraft-mc-backup
|
||||
name: mcl-backup-changeme
|
||||
resources:
|
||||
requests:
|
||||
cpu: 500m
|
||||
|
|
|
@ -63,5 +63,6 @@ export function getServerContainer(serverSpec) {
|
|||
|
||||
export function getBackupContainer(serverSpec) {
|
||||
const container = loadYaml("lib/k8s/configs/containers/minecraft-backup.yml");
|
||||
console.log(serverSpec);
|
||||
return container;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue