Safely update your application without losing any data
By Bisht Technologies Pvt Ltd • diploy.inComplete every item on this checklist before starting the update:
package.json → "version").env — Database credentials, API keys, Meta tokens, payment gateway secrets, SMTP settingsuploads/ — All user-uploaded media: profile photos, campaign images, template media, chat attachmentsPostgreSQL Database — All conversations, contacts, campaigns, templates, subscriptions, user accounts (managed by your DB service, not stored in the app folder)node_modules/ directory will be regenerated by npm install. It is safe to delete this folder — it does not contain any user data.| Path | Description |
|---|---|
server/ | Backend source code |
client/ | Frontend source code |
shared/ | Shared schemas and types |
packages/ | Internal packages (diploy-core) |
dist/ | Built output (regenerated by npm run build) |
package.json | Dependencies and scripts |
tsconfig.json | TypeScript configuration |
vite.config.ts | Frontend build configuration |
drizzle.config.ts | Database ORM configuration |
tailwind.config.ts | CSS framework configuration |
# Replace with your actual database credentials
pg_dump -U your_db_user -h your_db_host -d your_db_name > backup_$(date +%Y%m%d_%H%M%S).sql
If you are using a managed database (e.g., AWS RDS, DigitalOcean, Supabase), you can also create a snapshot from your hosting provider's dashboard.
# Create a timestamped backup of the entire application
cd /path/to/your/app
tar -czf ../whatsway_backup_$(date +%Y%m%d_%H%M%S).tar.gz \
--exclude='node_modules' \
--exclude='dist' \
.
# If uploads are stored locally on disk
cp -r uploads/ ../uploads_backup_$(date +%Y%m%d_%H%M%S)/
Choose the update method that matches how you received the new version:
If your application was deployed using Git, this is the fastest and safest method.
pm2 stop all
cd /path/to/your/whatsway-app
git pull origin main
If you have local changes that conflict, stash them first:
git stash
git pull origin main
git stash pop
.env file or uploads/ directory if they are untracked. Verify before pulling: run git status and confirm these files are not listed as tracked changes.Use this method if you received the update as a ZIP file (e.g., from CodeCanyon or direct download).
pm2 stop all
# From your local machine
scp whatsway-v3.x.x.zip user@your-server:/tmp/
cd /path/to/your/whatsway-app
# Save .env and uploads to a safe location
cp .env /tmp/.env.backup
cp -r uploads/ /tmp/uploads_safe/
# Remove old code directories (safe to delete)
rm -rf server/ client/ shared/ packages/ dist/
# Extract new code
unzip -o /tmp/whatsway-v3.x.x.zip -d /path/to/your/whatsway-app/
# Restore .env if it was overwritten
cp /tmp/.env.backup .env
# Restore uploads if they were overwritten
cp -r /tmp/uploads_safe/* uploads/
.env still contains your database URL, API keys, and Meta tokens. Open it with cat .env and confirm the values are present.npm install
This reads the new package.json and installs any added or updated packages. Your data is not affected.
npm run build
This compiles the frontend (React/Vite) and backend (TypeScript) into production-ready files in the dist/ directory.
npm install fails with permission errors, first try fixing directory ownership: sudo chown -R $(whoami) node_modules/. Only as a last resort, use: sudo npm install --unsafe-perm (avoid running npm as root on production systems when possible).The application uses Drizzle ORM with PostgreSQL. New versions may add columns or tables. The update process is non-destructive — it only adds new structures, never deletes existing data.
npm run db:push -- --force
This synchronizes the database schema with the latest code. The --force flag skips interactive prompts. In normal version upgrades, this adds new columns and tables to support new features.
db:push. While version upgrades are designed to be additive (adding columns/tables), the --force flag applies all schema changes without confirmation. A backup ensures you can recover if anything unexpected occurs.The application has a built-in startup migration system that automatically detects and adds any missing columns or tables when the server starts. This is a safety net that only performs additive changes (ADD COLUMN, CREATE TABLE). Running db:push explicitly is still preferred for full schema synchronization.
# Restart with PM2
pm2 restart all
# View logs to confirm startup
pm2 logs
You should see output similar to:
╔════════════════════════════════════════╗
║ DIPLOY ║
║ WhatsApp Marketing Platform v3.x ║
║ © Bisht Technologies Pvt Ltd ║
╚════════════════════════════════════════╝
[Diploy] Server running on port 5000
[startup-migration] All schema checks passed — database is up to date.
[startup-migration] Added X missing column(s), that means the self-healing migration successfully added new database fields. This is normal and expected.After restarting, verify everything is working:
pm2 logs --lines 100If something went wrong after updating, follow these steps to restore the previous version:
# Stop the app
pm2 stop all
# Check your Git log to find the previous version's commit
git log --oneline -5
# Reset to the previous version (replace COMMIT_HASH with the hash you want)
git reset --hard COMMIT_HASH
# Reinstall dependencies and rebuild
npm install
npm run build
# Restart
pm2 restart all
# Stop the app
pm2 stop all
# Restore from your backup archive
cd /path/to/your
tar -xzf whatsway_backup_YYYYMMDD_HHMMSS.tar.gz -C whatsway-app/
# Restore .env and uploads
cp /tmp/.env.backup whatsway-app/.env
cp -r /tmp/uploads_safe/* whatsway-app/uploads/
# Reinstall dependencies and rebuild
cd whatsway-app
npm install
npm run build
# Restart
pm2 restart all
Only restore the database backup if the new version caused data corruption (this is extremely rare):
# WARNING: This replaces ALL current data with the backup
psql -U your_db_user -h your_db_host -d your_db_name < backup_YYYYMMDD_HHMMSS.sql
Check the logs for errors:
pm2 logs --lines 200 --err
Common causes:
.env with the .env.example in the new version. New features may require new environment variables.pm2 delete all then pm2 start npm -- startpackage.json. Run node -v to verify. Node.js v18 or later is recommended.npm install failsnode_modules and package-lock.json, then run npm install againdf -hnode -v (v18 or later recommended)npm run build fails with memory error# Increase Node.js memory limit
NODE_OPTIONS=--max-old-space-size=2048 npm run build
db:push fails or hangsDATABASE_URL is set correctly in your .envpsql $DATABASE_URL -c "SELECT 1"--force flag: npm run db:push -- --forceSESSION_SECRET in .env hasn't changedWHATSAPP_VERIFY_TOKEN in .env matches your Meta app configurationuploads/ directory exists and has correct permissions: ls -la uploads/chown -R www-data:www-data uploads/ (or your app user).envContact support at cs@diploy.in with:
pm2 logsnode -v) and OSFor experienced users who have done this before, the entire update process can be run as a single command:
cd /path/to/your/app && git pull && npm install && npm run build && npm run db:push -- --force && pm2 restart all && pm2 logs
package.json includes a shortcut script npm run update:code, but it does not run npm install. If the new version adds or changes dependencies, use the full command above instead.