Database backup plugin for Medusa v2.10+ with improved reliability
This project is a fork of AmeerRizvi/medusa-backup, updated and optimized with the following improvements:
- ✅ Full compatibility with Medusa v2.10+
- ✅ Automatic rollback → if a backup fails midway, the database is safely restored to its previous state
If published under your npm scope (example: @anubus298/medusa-backup):
npm i @anubus298/medusa-backupOr install directly from GitHub:
npm install github:anubus298/medusa-backupmodule.exports = defineConfig({
...,
plugins: [
{
resolve: "@anubus298/medusa-backup",
options: {},
},
],
})Run database migrations:
npx medusa db:migrateDefault setup:
DATABASE_URL=postgres://[USERNAME]:[PASSWORD]@[HOST]/[DB]If you separate the DB base and name:
DB_BASE=postgres://[USERNAME]:[PASSWORD]@[HOST]
DB_NAME=[DB]-
PostgreSQL client (pg_dump) must be installed:
pg_dump --version
-
S3 configuration must be set up as described in Medusa documentation.
Example S3 config in medusa.config.ts:
module.exports = defineConfig({
modules: [
{
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "@medusajs/medusa/file-s3",
id: "s3",
options: {
file_url: process.env.S3_FILE_URL,
access_key_id: process.env.S3_ACCESS_KEY_ID,
secret_access_key: process.env.S3_SECRET_ACCESS_KEY,
region: process.env.S3_REGION,
bucket: process.env.S3_BUCKET,
endpoint: process.env.S3_ENDPOINT,
prefix: "resources/",
},
},
],
},
},
],
})Enable automatic backups in .env:
DB_BACKUP_AUTO=trueDefault schedule: daily at 1 AM. Customize with CRON:
DB_BACKUP_SCHEDULE="0 1 * * *"For more details, see crontab.guru.
- Backups are compressed (~70% smaller size).
- Backup failures are now handled gracefully with rollback support.
- PostgreSQL version should match your installed
pg_dumpandpsqltools. - Safe to restore production backups into local environments for testing.
- Added compatibility with Medusa v2.10+
- Introduced rollback mechanism for failed backups
- Optimized performance of backup creation
Forked from AmeerRizvi/medusa-backup. Big thanks to the original author for building the foundation of this plugin.