mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-17 12:33:06 +00:00
update backups
This commit is contained in:
@@ -1943,11 +1943,11 @@ export function generateSecrets(
|
||||
return envs;
|
||||
}
|
||||
|
||||
export async function backupPostgresqlDatabase(database, reply) {
|
||||
export async function backupDatabaseNow(database, reply) {
|
||||
const backupFolder = '/tmp'
|
||||
const fileName = `${database.id}-${new Date().getTime()}.gz`
|
||||
const backupFileName = `${backupFolder}/${fileName}`
|
||||
console.log({ database })
|
||||
const backupStorageFilename = `/app/backups/${fileName}`
|
||||
let command = null
|
||||
switch (database?.type) {
|
||||
case 'postgresql':
|
||||
@@ -1972,17 +1972,11 @@ export async function backupPostgresqlDatabase(database, reply) {
|
||||
dockerId: database.destinationDockerId,
|
||||
command,
|
||||
});
|
||||
const copyCommand = `docker cp ${database.id}:${backupFileName} ${backupFileName}`
|
||||
const copyCommand = `docker cp ${database.id}:${backupFileName} ${backupStorageFilename}`
|
||||
await executeCommand({
|
||||
dockerId: database.destinationDockerId,
|
||||
command: copyCommand
|
||||
});
|
||||
if (isDev) {
|
||||
await executeCommand({
|
||||
dockerId: database.destinationDockerId,
|
||||
command: `docker cp ${database.id}:${backupFileName} /app/backups/`
|
||||
});
|
||||
}
|
||||
const stream = fsNormal.createReadStream(backupFileName);
|
||||
reply.header('Content-Type', 'application/octet-stream');
|
||||
reply.header('Content-Disposition', `attachment; filename=${fileName}`);
|
||||
|
||||
@@ -5,7 +5,7 @@ import yaml from 'js-yaml';
|
||||
import fs from 'fs/promises';
|
||||
import {
|
||||
ComposeFile,
|
||||
backupPostgresqlDatabase,
|
||||
backupDatabaseNow,
|
||||
createDirectories,
|
||||
decrypt,
|
||||
defaultComposeConfiguration,
|
||||
@@ -362,7 +362,7 @@ export async function backupDatabase(request: FastifyRequest<OnlyId>, reply: Fas
|
||||
});
|
||||
if (database.dbUserPassword) database.dbUserPassword = decrypt(database.dbUserPassword);
|
||||
if (database.rootUserPassword) database.rootUserPassword = decrypt(database.rootUserPassword);
|
||||
return await backupPostgresqlDatabase(database, reply);
|
||||
return await backupDatabaseNow(database, reply);
|
||||
} catch ({ status, message }) {
|
||||
return errorHandler({ status, message });
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
loading.backup = true;
|
||||
addToast({
|
||||
message:
|
||||
'Backup will be downloaded soon and saved to /var/lib/docker/volumes/coolify-local-backup/ on the host system.',
|
||||
'Backup will be downloaded soon and saved to /var/lib/docker/volumes/coolify-local-backup/_data/ on the host system.',
|
||||
type: 'success',
|
||||
timeout: 15000
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user