Open lcrojano opened 1 month ago
@lcrojano use vercel cron job to automate the task?
Hi @Shu12388y!
I wanted to let you know that this workflow won’t work on Vercel. Instead, we can use GitHub Actions to automate the database backups!
this workflow file is added to the .github/workflows/ directory, and you can check the action in the Actions tab of your repository.
Steps to Set Up Environment Keys: Go to your repository's Settings. Click on Secrets and variables > Actions. Add the new secrets:
PRIMARY_DB_URI="mongodb://username:password@localhost:27017"
PRIMARY_DB_NAME="your_db_name"
BACKUP_RETENTION_LIMIT=2
After setting everything up, you can test the workflow manually in GitHub Actions, wait for the schedule, or by runnnig npm run backup:db
.
I am willing to discuss this further. Please feel free to contact me.
@Shu12388y If you prefer to use Vercel's cron jobs, I could update the PR also
Databas Backup GitHub Action Documentation
Resolves #93
Overview
This GitHub Action automates the process of backing up a MongoDB database. It schedules regular backups using a CRON expression and provides an option for manual execution. The backup is stored in a new database, and old backups are automatically deleted based on a specified retention limit.
Workflow Configuration
Workflow File:
.github/workflows/db-backup.yml
Secrets Configuration:
0 0 1 * *
for once a month).scripts/databaseBackup.js
).Usage Instructions
Running the Backup Script Manually
To run the backup script manually, trigger the GitHub Action from the Actions tab in your repository:
Automated Backups
For automated backups, ensure the
CRON_SCHEDULE
secret is set correctly. The workflow will run automatically based on the schedule defined in the CRON expression.Running the Backup Script with npm
If you want to run the backup script locally using
npm
, follow these steps: