mirror of
https://github.com/immich-app/immich.git
synced 2026-03-23 18:07:56 -04:00
* fix(server): use provided database name/username for restore & ensure name is not mangled fixes #25633 Signed-off-by: izzy <me@insrt.uk> * chore: add db switch back but with comments Signed-off-by: izzy <me@insrt.uk> * refactor: no need to restore database since it's not technically possible chore: late fallback for username in parameter builder Signed-off-by: izzy <me@insrt.uk> * chore: type fix Signed-off-by: izzy <me@insrt.uk> * refactor: move db backup code into service * test: check SQL sent to psql * chore: remove todo Signed-off-by: izzy <me@insrt.uk> --------- Signed-off-by: izzy <me@insrt.uk>
25 lines
865 B
TypeScript
25 lines
865 B
TypeScript
export function isValidDatabaseBackupName(filename: string) {
|
|
return filename.match(/^[\d\w-.]+\.sql(?:\.gz)?$/);
|
|
}
|
|
|
|
export function isValidDatabaseRoutineBackupName(filename: string) {
|
|
const oldBackupStyle = filename.match(/^immich-db-backup-\d+\.sql\.gz$/);
|
|
//immich-db-backup-20250729T114018-v1.136.0-pg14.17.sql.gz
|
|
const newBackupStyle = filename.match(/^immich-db-backup-\d{8}T\d{6}-v.*-pg.*\.sql\.gz$/);
|
|
return oldBackupStyle || newBackupStyle;
|
|
}
|
|
|
|
export function isFailedDatabaseBackupName(filename: string) {
|
|
return filename.match(/^immich-db-backup-.*\.sql\.gz\.tmp$/);
|
|
}
|
|
|
|
export function findDatabaseBackupVersion(filename: string) {
|
|
return /-v(.*)-/.exec(filename)?.[1];
|
|
}
|
|
|
|
export class UnsupportedPostgresError extends Error {
|
|
constructor(databaseVersion: string) {
|
|
super(`Unsupported PostgreSQL version: ${databaseVersion}`);
|
|
}
|
|
}
|