The StorageAdapter instance to backup
AWS SDK S3Client (works with S3, R2, MinIO, etc.)
The S3 bucket name
Scheduled backup configuration
CloudBackupManager instance ready to start
import { S3Client } from '@aws-sdk/client-s3';
import { createCloudBackupManager } from '@framers/sql-storage-adapter';
const s3 = new S3Client({ region: 'us-east-1' });
const manager = createCloudBackupManager(db, s3, 'my-bucket', {
interval: 60 * 60 * 1000, // 1 hour
maxBackups: 24,
options: { compression: 'gzip' }
});
manager.start();
import { S3Client } from '@aws-sdk/client-s3';
const r2 = new S3Client({
region: 'auto',
endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: process.env.R2_ACCESS_KEY_ID,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
},
});
const manager = createCloudBackupManager(db, r2, 'backups', {
interval: 24 * 60 * 60 * 1000, // Daily
maxBackups: 7
});
Create a cloud backup manager with S3-compatible storage.
This is the main factory function for setting up cloud backups. It creates an S3StorageProvider and CloudBackupManager configured with your database and S3-compatible storage.