From f4741c70f37bf176dbc4ac0853eb5887a12441be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Thu, 7 Nov 2024 03:57:36 -0800 Subject: [PATCH] fix(server): allow starting backup through API and fix pg_dumpall args when using database URLs (#13970) * fix(server): allow starting backup through API * fix(server): fix pg_dumpall args when using database URLs The database has to be specified using `-d`, unlike for pg_dump. --- server/src/services/backup.service.ts | 2 +- server/src/services/job.service.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/services/backup.service.ts b/server/src/services/backup.service.ts index fc470f188c..3dad4f1016 100644 --- a/server/src/services/backup.service.ts +++ b/server/src/services/backup.service.ts @@ -85,7 +85,7 @@ export class BackupService extends BaseService { } = this.configRepository.getEnv(); const isUrlConnection = config.connectionType === 'url'; - const databaseParams = isUrlConnection ? [config.url] : ['-U', config.username, '-h', config.host]; + const databaseParams = isUrlConnection ? ['-d', config.url] : ['-U', config.username, '-h', config.host]; const backupFilePath = path.join( StorageCore.getBaseFolder(StorageFolder.BACKUPS), `immich-db-backup-${Date.now()}.sql.gz.tmp`, diff --git a/server/src/services/job.service.ts b/server/src/services/job.service.ts index c368f95bfd..64490d4505 100644 --- a/server/src/services/job.service.ts +++ b/server/src/services/job.service.ts @@ -164,6 +164,10 @@ export class JobService extends BaseService { return this.jobRepository.queue({ name: JobName.LIBRARY_QUEUE_SYNC_ALL, data: { force } }); } + case QueueName.BACKUP_DATABASE: { + return this.jobRepository.queue({ name: JobName.BACKUP_DATABASE, data: { force } }); + } + default: { throw new BadRequestException(`Invalid job name: ${name}`); }