Types API Reference
This page documents all TypeScript interfaces and types used in backupx.
Core Configuration Types
BackupConfig
Main configuration interface for backup operations.
interface BackupConfig {
verbose: boolean
databases: DatabaseConfig[]
files: FileConfig[]
outputPath?: string
retention?: RetentionConfig
}
Properties:
verbose
- Enable detailed logging outputdatabases
- Array of database configurations to backupfiles
- Array of file/directory configurations to backupoutputPath
- Directory to store backup files (optional, defaults to './backups')retention
- Retention policy for old backups (optional)
DatabaseConfig
Base configuration for database backups.
interface DatabaseConfig {
type: BackupType
name: string
verbose?: boolean
compress?: boolean
filename?: string
}
Properties:
type
- Type of database (SQLite, PostgreSQL, MySQL)name
- Unique identifier for this backupverbose
- Override global verbose setting (optional)compress
- Enable compression for this backup (optional)filename
- Custom filename for backup file (optional)
SQLiteConfig
Configuration specific to SQLite database backups.
interface SQLiteConfig extends DatabaseConfig {
type: BackupType.SQLITE
path: string
}
Properties:
path
- File system path to the SQLite database file
PostgreSQLConfig
Configuration for PostgreSQL database backups.
interface PostgreSQLConfig extends DatabaseConfig {
type: BackupType.POSTGRESQL
connection: string | PostgreSQLConnectionObject
tables?: string[]
excludeTables?: string[]
includeSchema?: boolean
includeData?: boolean
}
Properties:
connection
- Connection string or connection objecttables
- Specific tables to backup (optional, defaults to all)excludeTables
- Tables to exclude from backup (optional)includeSchema
- Include table structure (optional, defaults to true)includeData
- Include table data (optional, defaults to true)
PostgreSQLConnectionObject
Object-based PostgreSQL connection configuration.
interface PostgreSQLConnectionObject {
hostname: string
port: number
database: string
username: string
password: string
ssl?: boolean | string
}
MySQLConfig
Configuration for MySQL database backups.
interface MySQLConfig extends DatabaseConfig {
type: BackupType.MYSQL
connection: MySQLConnectionObject
tables?: string[]
excludeTables?: string[]
includeSchema?: boolean
includeData?: boolean
}
MySQLConnectionObject
MySQL connection configuration object.
interface MySQLConnectionObject {
hostname: string
port: number
database: string
username: string
password: string
ssl?: boolean
}
FileConfig
Configuration for file and directory backups.
interface FileConfig {
name: string
path: string
verbose?: boolean
compress?: boolean
filename?: string
include?: string[]
exclude?: string[]
maxFileSize?: number
followSymlinks?: boolean
preserveMetadata?: boolean
}
Properties:
name
- Unique identifier for this backuppath
- File system path to backupverbose
- Override global verbose setting (optional)compress
- Enable compression (optional)filename
- Custom filename for backup archive (optional)include
- Glob patterns for files to include (optional)exclude
- Glob patterns for files to exclude (optional)maxFileSize
- Maximum file size to include in bytes (optional)followSymlinks
- Follow symbolic links (optional, defaults to false)preserveMetadata
- Preserve file metadata (optional, defaults to false)
RetentionConfig
Configuration for backup retention policies.
interface RetentionConfig {
count?: number
maxAge?: number
}
Properties:
count
- Maximum number of backups to keep (optional)maxAge
- Maximum age of backups in days (optional)
Result Types
BackupSummary
Summary of a complete backup operation.
interface BackupSummary {
startTime: Date
endTime: Date
duration: number
results: BackupResult[]
successCount: number
failureCount: number
totalSize: number
}
Properties:
startTime
- When the backup process startedendTime
- When the backup process completedduration
- Total duration in millisecondsresults
- Array of individual backup resultssuccessCount
- Number of successful backupsfailureCount
- Number of failed backupstotalSize
- Total size of all successful backups in bytes
BackupResult
Result of an individual backup operation.
interface BackupResult {
name: string
type: BackupType
filename: string
size: number
duration: number
success: boolean
error?: string
fileCount?: number
}
Properties:
name
- Name identifier of the backuptype
- Type of backup performedfilename
- Name of the created backup filesize
- Size of the backup file in bytesduration
- Time taken for this backup in millisecondssuccess
- Whether the backup succeedederror
- Error message if backup failed (optional)fileCount
- Number of files backed up (for file/directory backups, optional)
CleanupResult
Result of a retention cleanup operation.
interface CleanupResult {
deletedCount: number
deletedFiles: string[]
freedSpace: number
errors: string[]
}
Properties:
deletedCount
- Number of files deleteddeletedFiles
- Array of deleted file namesfreedSpace
- Amount of disk space freed in byteserrors
- Array of error messages for files that couldn't be deleted
Enum Types
BackupType
Enumeration of supported backup types.
enum BackupType {
SQLITE = 'SQLITE',
POSTGRESQL = 'POSTGRESQL',
MYSQL = 'MYSQL',
FILE = 'FILE',
DIRECTORY = 'DIRECTORY'
}
Values:
SQLITE
- SQLite database backupPOSTGRESQL
- PostgreSQL database backupMYSQL
- MySQL database backupFILE
- Individual file backupDIRECTORY
- Directory backup
BackupErrorCode
Error codes for backup operations.
enum BackupErrorCode {
INVALID_CONFIG = 'INVALID_CONFIG',
FILE_NOT_FOUND = 'FILE_NOT_FOUND',
PERMISSION_DENIED = 'PERMISSION_DENIED',
CONNECTION_FAILED = 'CONNECTION_FAILED',
DISK_FULL = 'DISK_FULL',
COMPRESSION_FAILED = 'COMPRESSION_FAILED',
DATABASE_ERROR = 'DATABASE_ERROR',
UNKNOWN_ERROR = 'UNKNOWN_ERROR'
}
Utility Types
ValidationResult
Result of configuration validation.
interface ValidationResult {
isValid: boolean
errors: string[]
warnings: string[]
}
Properties:
isValid
- Whether the configuration is validerrors
- Array of validation errorswarnings
- Array of validation warnings
BackupMetadata
Metadata about a backup file.
interface BackupMetadata {
filename: string
type: BackupType
name: string
created: Date
size: number
compressed: boolean
checksum?: string
}
Properties:
filename
- Name of the backup filetype
- Type of backupname
- Backup identifiercreated
- Creation timestampsize
- File size in bytescompressed
- Whether the backup is compressedchecksum
- File checksum for integrity verification (optional)
ProgressInfo
Information about backup progress.
interface ProgressInfo {
current: number
total: number
currentOperation: string
estimatedTimeRemaining?: number
}
Properties:
current
- Current progress counttotal
- Total operations to completecurrentOperation
- Description of current operationestimatedTimeRemaining
- Estimated time remaining in milliseconds (optional)
Type Guards
Utility functions for type checking.
isBackupResult
function isBackupResult(obj: any): obj is BackupResult {
return obj
&& typeof obj.name === 'string'
&& typeof obj.type === 'string'
&& typeof obj.success === 'boolean'
}
isDatabaseConfig
function isDatabaseConfig(config: any): config is DatabaseConfig {
return config
&& typeof config.type === 'string'
&& [BackupType.SQLITE, BackupType.POSTGRESQL, BackupType.MYSQL].includes(config.type)
}
isFileConfig
function isFileConfig(config: any): config is FileConfig {
return config
&& typeof config.name === 'string'
&& typeof config.path === 'string'
}
All types are exported from the main package and provide full TypeScript intellisense and type safety.