1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

fix(server): support non-default postgres port when taking a backup (#13992)

This commit is contained in:
Jason Rasmussen 2024-11-07 15:06:16 -05:00 committed by GitHub
parent ec5b7c266b
commit 7534098596
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,7 +80,22 @@ export class BackupService extends BaseService {
} = this.configRepository.getEnv();
const isUrlConnection = config.connectionType === 'url';
const databaseParams = isUrlConnection ? ['-d', config.url] : ['-U', config.username, '-h', config.host];
const databaseParams = isUrlConnection
? ['--dbname', config.url]
: [
'--username',
config.username,
'--host',
config.host,
'--port',
`${config.port}`,
'--database',
config.database,
];
databaseParams.push('--clean', '--if-exists');
const backupFilePath = path.join(
StorageCore.getBaseFolder(StorageFolder.BACKUPS),
`immich-db-backup-${Date.now()}.sql.gz.tmp`,
@ -88,8 +103,11 @@ export class BackupService extends BaseService {
try {
await new Promise<void>((resolve, reject) => {
const pgdump = this.processRepository.spawn(`pg_dumpall`, [...databaseParams, '--clean', '--if-exists'], {
env: { PATH: process.env.PATH, PGPASSWORD: isUrlConnection ? undefined : config.password },
const pgdump = this.processRepository.spawn(`pg_dumpall`, databaseParams, {
env: {
PATH: process.env.PATH,
PGPASSWORD: isUrlConnection ? undefined : config.password,
},
});
// NOTE: `--rsyncable` is only supported in GNU gzip