mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Improve production stability by fixing backup directory permissions
Adjust Dockerfile to create and grant permissions for backup directories, install PostgreSQL client for backups, and update BackupService to use the correct production backup path to resolve EACCES errors. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/7c468936-2a88-4686-ac0a-84921a45222d/K3Lzcje
This commit is contained in:
1 parent
1c126fb77a
commit
b079d35e3a
4 files changed
+262
-8
No files matched your search
+29
-4
@@ -15,15 +15,40 @@ export class BackupService {
|
||||
private maxBackups = 10;
|
||||
|
||||
constructor() {
|
||||
this.backupDir = path.join(process.cwd(), 'backups');
|
||||
// Use /app/backups in production (with proper permissions), or use env variable
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
this.backupDir = isProduction
|
||||
? process.env.BACKUP_DIR || '/app/backups'
|
||||
: path.join(process.cwd(), 'backups');
|
||||
|
||||
this.ensureBackupDirectory();
|
||||
this.scheduleAutomaticBackup();
|
||||
}
|
||||
|
||||
private ensureBackupDirectory(): void {
|
||||
if (!fs.existsSync(this.backupDir)) {
|
||||
fs.mkdirSync(this.backupDir, { recursive: true });
|
||||
console.log('📁 Backup directory created:', this.backupDir);
|
||||
try {
|
||||
if (!fs.existsSync(this.backupDir)) {
|
||||
fs.mkdirSync(this.backupDir, { recursive: true });
|
||||
console.log('📁 Backup directory created:', this.backupDir);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to create backup directory:', error);
|
||||
// Fallback to /tmp if current directory fails
|
||||
if (this.backupDir !== '/tmp/backups') {
|
||||
this.backupDir = '/tmp/backups';
|
||||
console.log('🔄 Falling back to /tmp/backups');
|
||||
try {
|
||||
if (!fs.existsSync(this.backupDir)) {
|
||||
fs.mkdirSync(this.backupDir, { recursive: true });
|
||||
console.log('📁 Fallback backup directory created:', this.backupDir);
|
||||
}
|
||||
} catch (fallbackError) {
|
||||
console.error('❌ Failed to create fallback directory:', fallbackError);
|
||||
throw fallbackError;
|
||||
}
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user