@anubus298/medusa-backup
v1.6.6
Published
DB Backup and Restore for Medusa.js, forked, optimized & compatible with medusa v2.10+
Maintainers
Readme
Medusa Backup (Forked & Enhanced)
✨ What’s New in This Fork
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
🚀 Installation
If published under your npm scope (example: @anubus298/medusa-backup):
npm i @anubus298/medusa-backupOr install directly from GitHub:
npm install github:anubus298/medusa-backup⚙️ Configuration
medusa.config.ts
module.exports = defineConfig({
...,
plugins: [
{
resolve: "@anubus298/medusa-backup",
options: {},
},
],
})Run database migrations:
npx medusa db:migrate🔑 Environment Variables
Default 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]🛠 Requirements
PostgreSQL client (pg_dump) must be installed:
pg_dump --versionS3 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/",
},
},
],
},
},
],
})🔄 Automatic Backups
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. ⚠️ Automatic backups run only in production.
📝 Notes
- 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.
📜 Changelog
v2.10.x+
- Added compatibility with Medusa v2.10+
- Introduced rollback mechanism for failed backups
- Optimized performance of backup creation
🙏 Credits
Forked from AmeerRizvi/medusa-backup. Big thanks to the original author for building the foundation of this plugin.
