JSPM

database-backup

0.0.5
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 7
    • Score
      100M100P100Q43393F
    • License MIT

    A NestJS dynamic module for backing up PostgreSQL databases using pg_dump.

    Package Exports

    • database-backup
    • database-backup/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (database-backup) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    πŸ“¦ database-backup

    A NestJS dynamic module for backing up PostgreSQL databases using the native pg_dump utility. This package allows you to easily integrate PostgreSQL backup functionality into your NestJS applications.


    Installation

    npm install database-backup

    ⚠️ Make sure you have pg_dump installed and available in your system’s PATH. It is included by default with PostgreSQL installations.


    πŸ“– Usage

    1. Import the Module

    In your AppModule (or any feature module):

    import { Module } from '@nestjs/common';
    import { BackupModule } from 'database-backup';
    
    @Module({
      imports: [
        BackupModule.register({
          host: 'localhost',
          port: 5432,
          databaseUsername: 'postgres',
          databasePassword: 'your_password',
          // Optional: pgDumpPath: '/path/to/pg_dump'
        }),
      ],
    })
    export class AppModule {}

    2. Use the Service

    Inject the BackupService anywhere you need to trigger a backup:

    import { Injectable } from '@nestjs/common';
    import { BackupService } from 'database-backup';
    
    @Injectable()
    export class AppService {
      constructor(private readonly backupService: BackupService) {}
    
      async runBackup() {
        await this.backupService.backupSingleDatabase('my_database');
      }
    }

    βš™οΈ Configuration Options

    Option Type Required Description
    host string βœ… Database host (e.g., localhost)
    port number βœ… Database port (default: 5432)
    databaseUsername string βœ… PostgreSQL username
    databasePassword string βœ… PostgreSQL password
    pgDumpPath string ❌ Optional path to pg_dump binary (if not in system PATH)

    πŸ“‚ Backup Output

    Backups are saved in the current working directory as:

    <database-name>-backup.sql

    Example:

    my_database-backup.sql

    πŸ”‘ Peer Dependencies

    This package requires the following peer dependencies:

    • @nestjs/core (v11+)
    • @nestjs/common (v11+)

    Ensure they are installed in your NestJS project.


    πŸ“ License

    MIT Β© 2025 \Shaheel Abbasi