npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tmlmobilidade/env-sync

v20260306.1635.14

Published

CLI tool to sync production and staging environments (MongoDB and Storage)

Readme

Environment Sync CLI

CLI tool to sync production and staging environments for MongoDB and Storage (using RClone).

Installation

npm install
npm run build

Usage

Basic Usage

# Sync both MongoDB and Storage (interactive mode)
npm run dev

# Run with arguments (use -- to pass arguments to the script)
npm run dev -- --help
npm run dev -- --db-only
npm run dev -- --storage-only

# Or after building:
./dist/index.js
./dist/index.js --help

Command Line Options

# Sync only MongoDB database
env-sync --db-only

# Sync only storage
env-sync --storage-only

# Use replica set mode
env-sync --replica-set

# Skip cleanup of old backups
env-sync --no-cleanup

# Upload backup artifacts to OCI bucket (for CI/CD, replaces GitHub artifacts)
env-sync --db-only --upload-artifacts

# Show help
env-sync --help

Configuration

Create a .env file in the cli/env-sync-ts/ directory with the following variables:

MongoDB Configuration

# Production MongoDB
PROD_HOST=production-mongo-host:27017
PROD_USERNAME=admin
PROD_PASSWORD=password
PROD_AUTH_DATABASE=admin
PROD_DB=production_database

# Staging MongoDB
STAGING_HOST=staging-mongo-host:27017
STAGING_USERNAME=admin
STAGING_PASSWORD=password
STAGING_AUTH_DATABASE=admin
STAGING_DB=staging_database

# Optional: Collections to exclude from sync (space-separated)
EXCLUDE_COLLECTIONS=logs sessions temp_data

# Optional: Backup retention days (default: 7)
BACKUP_RETENTION_DAYS=7

Storage Configuration (OCI/RClone)

# RClone Configuration
STORAGE_REMOTE_NAME=oci_storage
STORAGE_TYPE=oracleobjectstorage
STORAGE_SOURCE=production-bucket/path/to/source
STORAGE_DEST=staging-bucket/path/to/dest

# OCI Authentication
OCI_USER=ocid1.user.oc1..
OCI_FINGERPRINT=aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99
OCI_KEY_FILE=/path/to/private_key.pem
OCI_TENANCY=ocid1.tenancy.oc1..
OCI_REGION=us-ashburn-1
OCI_COMPARTMENT=ocid1.compartment.oc1..
OCI_NAMESPACE=your_namespace

Artifacts Configuration (for CI/CD)

# OCI bucket for storing backup artifacts (required for --upload-artifacts)
ARTIFACTS_BUCKET=your-artifacts-bucket

# Optional: prefix/folder within the bucket (default: "env-sync")
ARTIFACTS_PREFIX=env-sync

MongoDB Backup Strategy

  • Full database dump with all collections (excluding configured collections)
  • Dumps all collections from production database
  • Restores to staging database with --drop flag

Backup Metadata

  • Backup metadata is stored in backups/.backup_metadata
  • Tracks last backup timestamp

Storage Sync

  • Uses RClone to sync files from production OCI storage to staging
  • Configured via environment variables (no rclone config file needed)
  • Progress reporting during sync

Development

# Run in development mode
npm run dev

# Build
npm run build

# Lint
npm run lint

Requirements

  • Node.js (v18+)
  • MongoDB tools (mongodump, mongorestore)
  • RClone (rclone)

Notes

  • The script maintains compatibility with the existing bash scripts' .env file format
  • Backups are stored in backups/ directory
  • Old backups are automatically cleaned up (configurable retention period)
  • Interactive prompts use Clack for a modern CLI experience