NMX migration / upgrade command cheat sheet ========================================== Generated: 2026-11-09 (America/New_York) Sources: /workspace migration scripts (biz7-to-ww7, nmx8-to-ww7, sync/rsync helpers), WW7 /root/backups CHANGES/RESTORE/ROLLBACK notes, this agent's Nov 6-9 WW7 work, and ALS->NMX8 Directus/Apollo cutover notes under /workspace/agent-tools. SearchTranscripts across other sessions returned no hits from this run — do not treat this as a complete transcript dump. Secrets redacted as , , , etc. ---------------------------------------------------------------- 1) Finding things (grep / find / rg patterns actually used) ---------------------------------------------------------------- # Apache / tunnel / db host refs grep -RIn --include='*.conf' -E 'ServerName|DocumentRoot|mynutramax' /etc/apache2/sites-enabled grep -rhoE 'ws\.nutramax\.(com|biz)|www\.nutramax\.biz' /etc/cloudflared/ /root/.cloudflared/ 2>/dev/null | sort -u grep -rhE 'hostname:' /etc/cloudflared/*.yml 2>/dev/null grep -rlE 'mdb|ondigitalocean' /etc/apache2 /var/www 2>/dev/null | head # Code / config search with secret scrubbing (biz7mig.sh pattern) R='s/(pass(word)?|pwd|secret|token|key|apikey)(["'"'"' ]*[:=>,]+ *["'"'"']?)[^"'"'"' ,;)]+/\1\3/Ig' grep -rIhoE "(DB_HOST|db_host|host)['\" ]*[:=>]+ *['\"][^'\"]{3,60}['\"]" /var/www/html \ --include=*.php --include=*.js --include=*.json --include=*.env --exclude-dir=node_modules \ | sort | uniq -c | sort -rn | head -15 # Mount / process discovery findmnt -T /var/www/EP1 grep -E 'EP1|/var/www/EP1' /proc/mounts mount | grep -E 'EP1|sshfs' find /opt/code-server -name 'workbench.html' find /root/backups -maxdepth 3 \( -iname 'CHANGES*' -o -iname 'RESTORE*' -o -iname 'ROLLBACK*' \) # Inventory helpers on box # /workspace/nmx8-to-ww7/inv.py inv2.py inv3.py — DO/CF inventory dumps # /workspace/nmx8-to-ww7/INVENTORY.md — summarized NMX8->WW7 inventory ---------------------------------------------------------------- 2) Copying files (scp / rsync / cp / tar) ---------------------------------------------------------------- # Preserve ownership/mode when replacing a live file (pattern used often on WW7) sudo cp -a --preserve=all /path/to/live /root/backups/-YYYYMMDD/ sudo install -o -g -m /tmp/newfile /path/to/live # or: cp -a source dest; then chown/chmod to match prior stat # Atomic replace pattern (HTML recovery 2026-11-06) cp -a --preserve=all workbench.html .workbench.html.recovery-tmp # write new bytes into tmp, chown/chmod to match original, then: os.replace(tmp, workbench.html) # Python; or mv -T tmp live # rsync dry-run of mynutramax www from NMX2 -> WW7 (s7.sh) cd /var/www/html/mynutramax.com/www TS=$(date -u +%Y%m%dT%H%M%SZ) EX=/root/php83-fixes/ww7-www-final-sync-exclude.$TS.list { grep -rl --include=*.php "/etc/nmx/" . | sed 's#^\./#/#'; echo '/.htaccess'; echo '*.bkp2026*'; } > $EX nice -n19 ionice -c3 rsync -ani --exclude-from=$EX \ -e "ssh -i /root/.ssh/nmx-ssh -o BatchMode=yes" \ root@165.245.137.189:/var/www/html/mynutramax.com/www/ ./ \ > /root/php83-fixes/ww7-www-final-sync-dryrun.$TS.txt # tar backups tar czf /root/php83-fixes/ww7-mynutramax-www-php-before-mdb.$TS.tgz -C /var/www/html/mynutramax.com/www . tar czf $BK $paths && chmod 600 $BK # Box <-> WW7 (executor pattern) scp -o BatchMode=yes -o IdentitiesOnly=yes -i /workspace/nmx8-ssh/nmx8_ed25519 \ localfile ww7-tunnel:/tmp/ ssh -o BatchMode=yes -o IdentitiesOnly=yes -i /workspace/nmx8-ssh/nmx8_ed25519 ww7-tunnel '...' # Directus uploads at cutover (from ALS->NMX8 notes; exact flags not in a saved .sh here) # Narrative: "re-copy both directus/uploads folders with rsync, then restart the pm2 apps." # Exact rsync line for uploads was NOT recovered as a standalone script in /workspace — gap. ---------------------------------------------------------------- 3) Directus instance migrations / upgrades ---------------------------------------------------------------- Evidence is strongest in cutover status notes (/workspace/agent-tools/*), not as a single shell playbook. Documented outcomes / intended steps: Layout on NMX8: - Native pm2 as user webstack, Node 22.x - Ecosystem: /home/webstack/etc/ecosystem.nmx8.config.js - systemd: pm2-webstack enabled at boot - Examples (ports from notes): Solliquin Directus :8157 (with Stack :9008, Apollo :4001) Denamarin Directus :8153 (Stack :9003) Cosequin (ALS1) Directus :8356 (Stack :9302, Apollo :4301) Welactin (ALS5) directus :4100 (apollo :4101, nws :4102) leads / human-leads / api-als3 / stage-po Directus ports per ALS5 table in notes Databases: - Imported into DigitalOcean managed MySQL (mdb) over TLS - Per-DB user _app with REQUIRE SSL; passwords only in NMX8 .env (mode 600) - Directus: DB_POOL__MAX=5 (or 2–3 on some ALS5 apps), DB_SSL__CA_FILE / reject unauthorized - Redis: local redis-server 127.0.0.1; Denamarin Directus on Redis DB 2 (sharing schema cache with Solliquin broke Denamarin GraphQL — noted risk) Final sync at cutover (stated procedure): 1. Pause Directus admin edits on ALS4 (or read-only / stop admin) 2. Re-dump solliquin_live and denamarin_live 3. Drop/re-import on mdb with doadmin (admin cnf may need fresh fetch) 4. Recheck row counts 5. rsync directus/uploads 6. Restart pm2 apps Useful checks seen in tooling: pm2 jlist systemctl is-active pm2-webstack curl health endpoints /server/health (site-specific) GAP: No saved one-liner for "npx directus upgrade" / package version bumps was found in /workspace scripts. Treat upgrades as app-directory npm/pm2 work unless Jeremy points at a specific ALS/NMX8 script. ---------------------------------------------------------------- 4) Apollo instance work ---------------------------------------------------------------- From the same NMX8 cutover notes: - Apollo runs alongside Stack + Directus under pm2 (webstack) - Example ports: Solliquin Apollo 4001; Cosequin Apollo 4301; Welactin apollo 4101; contact-hcp apollo 4000; contact.mynutramaxlabs.com apollo 8076 - "Apollo was patched to use TLS" for mdb (exact patch command/file not in a standalone /workspace script recovered here — gap) - Verification pattern used publicly: curl -s -o /dev/null -m20 -w '%{http_code}' https://www.solliquin.com/ (and sibling brand URLs via /workspace/nmx8-to-ww7/pub.sh) Local origin check while on the host (/workspace/nmx8-to-ww7/lc.sh): for h in www.cosequin.com www.solliquin.com www.denamarin.com ...; do echo "$(curl -sk -o /dev/null -m20 -w '%{http_code}' --resolve $h:443:127.0.0.1 https://$h/) $h" done ---------------------------------------------------------------- 5) NMX8 inventory / move toward WW7 ---------------------------------------------------------------- Key artifacts: /workspace/nmx8-to-ww7/INVENTORY.md and dumps (dns-nmx8.json, tunnels.json, do-firewalls.json, db-mdb-firewall.json, ruleset-*.json). Highlights from INVENTORY.md (2026-11-04): - Tunnel b3f26aaa (nmx8) remote-managed; many CNAMEs already point at tunnel - mdb trusted sources included WW7 + NMX8 droplet ids - EP1: Host ep1 -> 10.108.0.5 (VPC); Caddy nwpc reverse_proxy to NMX8 private IP - CF rules already listed both NMX8 public and WW7 IPs in several places SSH alias pattern used from box/WW7: ssh -i /workspace/nmx8-ssh/nmx8_ed25519 -o UserKnownHostsFile=... root@167.71.102.164 # often wrapped as Host ww7-tunnel in executor SSH config ---------------------------------------------------------------- 6) BIZ7 -> WW7 cutover (Cloudflare tunnel + DNS API) ---------------------------------------------------------------- Scripts: /workspace/biz7-to-ww7/{common.sh,cutover.sh,rollback.sh} Hosts: erp.nutramax.com erp.nutramax.biz biz4.nutramax.info biz4.nutramax.com app-erp.nutramax.com Tunnel: b3f26aaa-65ab-47b9-940a-f21d35b6061c (CNAME .cfargotunnel.com) Origin service in tunnel: http://127.0.0.1:80 Export before use: export CF_NUTRAMAX_API_TOKEN='' export CF_NUTRAMAX_ACCOUNT_ID='' # Cut one hostname ./cutover.sh erp.nutramax.com What cutover.sh does (actual steps): 1) Backup DNS + tunnel config JSON under /workspace/biz7-to-ww7/backups/ curl -sf -H "Authorization: Bearer $CF_NUTRAMAX_API_TOKEN" -H "Content-Type: application/json" \ "$API/zones/$Z/dns_records?name=$H" > "$BK/$H.dns.$TS.json" curl ... "$API/accounts/$CF_NUTRAMAX_ACCOUNT_ID/cfd_tunnel/$TUN/configurations" > "$BK/tunnel.$H.$TS.json" 2) PUT tunnel ingress: insert {hostname, service: http://127.0.0.1:80} before catch-all 3) app-erp.nutramax.com special case: WW7: sudo -u webstack pm2 start /home/webstack/biz7-erp/ecosystem.config.js && pm2 save later stop Shopify Orders on BIZ7 via: ssh -n biz7 'pm2 stop "Shopify Orders" && pm2 save' 4) PUT DNS record to CNAME tunnel, proxied:true 5) curl -s -o /dev/null -w "%{http_code}\n" -m 15 "https://$H/" # Rollback one hostname ./rollback.sh erp.nutramax.com # restores DNS from $BK/$H.dns.original.json, removes ingress hostname, pm2 start/stop inverse BIZ9 cutover rollback helper: python3 /workspace/nmx8-to-ww7/rollback-biz9-cutover-20261104.py # PATCH DNS records from biz9-dns-pre-cutover JSON; PUT pre-biz9 tunnel config ---------------------------------------------------------------- 7) DB moves to managed cluster (mdb) ---------------------------------------------------------------- Pattern from /workspace/sync.sh (nmx_dashboard db3 -> mdb): M="--defaults-extra-file=/root/.mdbadmin.cnf" # contains user/password — do not copy live D="--defaults-extra-file=/root/.db3www.cnf" # Backup destination first nice -n19 mysqldump $M --single-transaction --set-gtid-purged=OFF --no-tablespaces \ --triggers --routines nmx_dashboard > $B/mdb-nmx_dashboard-before-sync.$TS.sql # Dump source (ignore broken views if needed) nice -n19 ionice -c3 mysqldump $D --single-transaction --quick --no-tablespaces \ --column-statistics=0 --set-gtid-purged=OFF --skip-lock-tables --triggers $IGN nmx_dashboard \ > $B/db3-nmx_dashboard.$TS.sql # Load into mdb (strip DEFINER) { echo "SET SESSION sql_require_primary_key=0;"; sed -E 's/DEFINER=`[^`]*`@`[^`]*`//g' $B/db3-nmx_dashboard.$TS.sql; } \ | nice -n19 mysql $M nmx_dashboard # Row-count compare loop (per BASE TABLE) — see sync.sh Related WW7 backup topic dirs (metadata only here): /root/backups/biz7-db3-to-mdb-20261104/ /root/backups/php-old-remove-20261104/ /root/backups/fpm83-children-20261104/ ---------------------------------------------------------------- 8) PHP / FPM / Apache on WW7 ---------------------------------------------------------------- # Version / package inventory style (biz7patch.sh / php notes) php -v apache2 -v dpkg -l 'php*' | head ls /etc/php systemctl list-units --type=service --state=running | grep -E 'php|apache|fpm' # After file edits that Apache/PHP read from disk: usually no restart needed for .php; # FPM pool / php.ini changes: systemctl reload php8.3-fpm (or restart) # WW7 often uses mod_php 8.4 (sury) for many vhosts — see jbackus comments: # # jbackus 20261104 - mod_php 8.4, was: Include /etc/apache2/snippets/php83-fpm.conf # RemoteIP (real client IP behind Cloudflare) — conf comment normalized Nov 5: # /etc/apache2/conf-available/remoteip-cloudflare.conf # RemoteIPHeader CF-Connecting-IP # RemoteIPTrustedProxy # RemoteIPInternalProxy 127.0.0.1 ::1 # RemoteIPInternalProxy 10.108.0.5 # EP1 php -l /path/to/file.php # lint before deploy (used for reset_password.php) ---------------------------------------------------------------- 9) Cloudflare tunnel / DNS / rules (API) ---------------------------------------------------------------- API=https://api.cloudflare.com/client/v4 AUTH=(-H "Authorization: Bearer $CF_NUTRAMAX_API_TOKEN" -H "Content-Type: application/json") # List DNS curl -sf "${AUTH[@]}" "$API/zones/$ZONE_ID/dns_records?name=erp.nutramax.com" # Update DNS curl -sf "${AUTH[@]}" -X PUT "$API/zones/$ZONE_ID/dns_records/$REC_ID" \ --data '{"type":"CNAME","name":"erp.nutramax.com","content":".cfargotunnel.com","proxied":true,"comment":"2026-11-04 JBACKUS: moved from BIZ7 to WW7 tunnel"}' # Tunnel configuration get/put curl -sf "${AUTH[@]}" "$API/accounts/$CF_NUTRAMAX_ACCOUNT_ID/cfd_tunnel/$TUN/configurations" curl -sf "${AUTH[@]}" -X PUT "$API/accounts/$CF_NUTRAMAX_ACCOUNT_ID/cfd_tunnel/$TUN/configurations" --data @/tmp/ing.json # NMX001 temporary admin exceptions were added then fully removed 2026-11-06 # Rollback helper: /workspace/cf-nmx001-backup/rollback.py # Backups: /workspace/cf-nmx001-backup/ and WW7 /root/backups/cf-nmx001-20261106/ cloudflared / system checks: systemctl is-active cloudflared journalctl -u cloudflared --since "-15min" --no-pager | grep -iE 'err|fail|unable|timeout' ---------------------------------------------------------------- 10) pm2 ---------------------------------------------------------------- # As webstack on WW7 (ERP / migrated node apps) sudo -u webstack pm2 start /home/webstack/biz7-erp/ecosystem.config.js sudo -u webstack pm2 save sudo -u webstack pm2 stop "BIZ7 Shopify Orders (app-erp.nutramax.com)" sudo -u webstack pm2 jlist # On BIZ7 during cutover ssh -n biz7 'pm2 stop "Shopify Orders" && pm2 save' ssh -n biz7 'pm2 start "Shopify Orders" && pm2 save' # Inspect pm2 jlist | python3 -c 'import sys,json; ...' systemctl cat pm2-webstack 2>/dev/null | head ---------------------------------------------------------------- 11) ufw / SSH hardening (WW7) ---------------------------------------------------------------- Backup topic: /root/backups/ww7-ssh-restrict-20261105/ (ufw-status-*.txt, iptables-save.txt, cloudflared-ps.txt, ss-22.txt) Typical inspect commands used: ufw status verbose ufw status numbered ss -lntp | grep ':22' iptables-save | head Do not paste live ufw allow rules with tokens here — re-read the backup dir before changing. Pattern: backup numbered status -> change one rule -> re-check ss/ufw -> keep cloudflared path working. ---------------------------------------------------------------- 12) sshfs mounts (EP1 / legacy BIZ7) ---------------------------------------------------------------- Service: nmx-remote-mounts.service Script: /usr/local/sbin/nmx-remote-mounts.sh # Effective live mounts (Nov 6/9 inspect): # ep1:/etc -> /var/www/EP1/.etc (fuse.sshfs) # ep1:/var -> /var/www/EP1/.var # ep1:/root -> /var/www/EP1/.root # /var/www/EP1 itself is a LOCAL directory on /dev/vda1 (not a mount) # ep1 SSH: HostName 10.108.0.5 User root Sanitized mount helper body: O=reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,allow_other m(){ mkdir -p "$2"; mountpoint -q "$2" && return 0; for i in 1 2 3 4 5; do sshfs "$1" "$2" -o $O && return 0; sleep 20; done; } m ep1:/var /var/www/EP1/.var m ep1:/etc /var/www/EP1/.etc m ep1:/root /var/www/EP1/.root # BIZ7 sshfs lines commented after droplet shutdown (2026-11-04) # Unmount sshfs (um2.sh style) mount -t fuse.sshfs | awk '{print $3}' | sort -r > /tmp/m.lst while read d; do timeout 10 fusermount -uz "$d" || timeout 10 umount -l "$d"; done < /tmp/m.lst systemctl status nmx-remote-mounts.service systemctl show var-www-EP1-.etc.mount -p Where -p What -p Type ---------------------------------------------------------------- 13) Backup / rollback patterns (WW7) ---------------------------------------------------------------- Convention: /root/backups/-YYYYMMDD/ CHANGES.txt or ROLLBACK.txt or RESTORE.txt copies of files with original ownership (cp -a --preserve=all) Examples: /root/backups/stg-reset_password-20261106/ /root/backups/admin-users-pwreset-20261109/ /root/backups/reset-allowlist-trim-20261109/ /root/backups/nmxcode-csp-fonts-20261106/CHANGES.txt /root/backups/nmxcode-html-recovery-20261106-221313/ /root/backups/dot-tmp-20261106/RESTORE.txt /root/backups/ww7-fpm-pool-20261105/ROLLBACK.txt Generic rollback: sudo cp -a --preserve=all /root/backups// /path/to/live # restart only if process caches the file (code-server, php-fpm, apache graceful) CF/DNS rollback: restore JSON backup via API PUT/PATCH (see sections 6–9). ---------------------------------------------------------------- 14) Visible WW7 work via nmxcode tmux (executor pattern) ---------------------------------------------------------------- SOCK=/tmp/tmux-1004/default sudo -u nmxcode -H tmux -S "$SOCK" new-session -d -s # e.g. pwreset, csp, notes, mount sudo -u nmxcode -H tmux -S "$SOCK" send-keys -t '=:' 'bash /tmp/script.sh' Enter sudo -u nmxcode -H tmux -S "$SOCK" capture-pane -t '=:' -p -S -120 Keep secrets out of pane output (sed redaction, avoid echoing tokens). ---------------------------------------------------------------- 15) Admin password-reset work (stg/www) — Nov 6–9 ---------------------------------------------------------------- # Handler (direct prod DB, office allowlist, POST + same-origin): # /var/www/html/mynutramax.com/stg/admin/reset_password.php # /var/www/html/mynutramax.com/www/admin/reset_password.php # Uses: require /etc/nmx/nmx_dash_www.php ; nmx_dash_www_connect("nmx_dashboard") # Final allowlist (after 2026-11-09 trim): # 208.104.82.162 159.254.202.62 159.254.202.94 # JS: stg/admin/users/nmx.js and users.v4 post to /admin/reset_password.php # www/admin/users/nmx.js already posted there; www handler was upgraded to direct reset php -l /var/www/html/mynutramax.com/stg/admin/reset_password.php # Gate tests: POST-only, origin check, REMOTE_ADDR allowlist (do not trust raw XFF) # DB test: BEGIN; UPDATE ...; ROLLBACK on tstvet@nutramaxlabs.info — no permanent change ---------------------------------------------------------------- 16) Gaps (little or no primary command evidence found) ---------------------------------------------------------------- - SearchTranscripts from this executor session returned empty for other runs; commands here are from files/backups/notes, not a full chat replay. - Exact Directus CLI upgrade commands (npm version / npx directus database migrate) not found as saved scripts. - Exact Apollo TLS patch file/diff not located as a standalone artifact (outcome noted only). - Exact live rsync flags for directus/uploads at cutover not recovered (procedure noted). - Full root bash_history was not dumped into this sheet (secret risk); use topic backups. - locate(1) usage was not a primary tool in these scripts (find/grep/rg preferred). END ---------------------------------------------------------------- 17) normal directus ops (standard reference examples — not from migration log) ---------------------------------------------------------------- # layout on ww7 (webstack): apps under /home/webstack//{live,stage,dev}/directus # start via pm2 / ecosystem: /home/webstack/etc/ecosystem.nmx8.config.js # (also ecosystem.config.js, ecosystem.als1.config.js; als5 often under nodejs user) # example pm2 names seen live: # "Directus Solliquin Live" cwd .../solliquin.com/live/directus (npx directus start) # "Denamarin Directus Live" cwd .../denamarin.com/live/directus # "ALS1 Cosequin Live Directus" cwd .../cosequin.com/live/directus # stack PORT examples from ecosystem: solliquin live stack PORT 9008, denamarin 9003 # directus package versions on disk: mostly 11.17.4 (live) / ^10.6.1 (some stage/dev) # list / status sudo -u webstack pm2 list sudo -u webstack pm2 describe "Directus Solliquin Live" sudo -u webstack pm2 show "Directus Solliquin Live" # restart directus (pm2) sudo -u webstack pm2 restart "Directus Solliquin Live" sudo -u webstack pm2 restart "Denamarin Directus Live" sudo -u webstack pm2 restart "ALS1 Cosequin Live Directus" # stop / start sudo -u webstack pm2 stop "Directus Solliquin Live" sudo -u webstack pm2 start "Directus Solliquin Live" # or start from ecosystem file sudo -u webstack pm2 start /home/webstack/etc/ecosystem.nmx8.config.js --only "Directus Solliquin Live" sudo -u webstack pm2 save # logs sudo -u webstack pm2 logs "Directus Solliquin Live" --lines 100 sudo -u webstack pm2 logs "Directus Solliquin Live" --err --lines 50 # run npx in the app dir (uses that package's directus version + local .env) cd /home/webstack/solliquin.com/live/directus sudo -u webstack -H bash -lc 'cd /home/webstack/solliquin.com/live/directus && npx directus --help' # database migrate / bootstrap (standard directus cli — confirm version help first) cd /home/webstack/solliquin.com/live/directus sudo -u webstack -H bash -lc 'cd /home/webstack/solliquin.com/live/directus && npx directus database migrate:latest' sudo -u webstack -H bash -lc 'cd /home/webstack/solliquin.com/live/directus && npx directus database migrate:down' # bootstrap only on empty/new installs — destructive if misused # sudo -u webstack -H bash -lc 'cd /home/webstack/solliquin.com/live/directus && npx directus bootstrap' # admin users (prompts / args vary by major version — check --help) sudo -u webstack -H bash -lc 'cd /home/webstack/solliquin.com/live/directus && npx directus users create --help' # example shape (placeholders only): # npx directus users create --email --password '' --role # npx directus users passwd --email --password '' # als5-style apps (nodejs user) — same idea, different home # sudo -u nodejs pm2 restart "ALS5 welactin-live-directus" # cd /home/nodejs/welactin.com/live/directus && npx directus start # usually via pm2 ---------------------------------------------------------------- 18) normal apollo ops (standard reference examples — not from migration log) ---------------------------------------------------------------- # apollo lives next to stack/directus; server entry typically: # /home/webstack//live/apollo/server/src/index.js # pm2 names seen: # "Apollo Solliquin Live" / "Apollo Solliquin Dev" # "ALS1 Cosequin Live Apollo" # als5 examples: "ALS5 welactin-live-apollo", "ALS5 contact-hcp.nutramax.com-apollo" # env often via ecosystem or --env-file=/home/.../apollo/.env (do not cat secrets) # status / restart sudo -u webstack pm2 list sudo -u webstack pm2 restart "Apollo Solliquin Live" sudo -u webstack pm2 stop "Apollo Solliquin Live" sudo -u webstack pm2 start "Apollo Solliquin Live" sudo -u webstack pm2 logs "Apollo Solliquin Live" --lines 100 # run by hand for debug (prefer pm2 in prod) cd /home/webstack/solliquin.com/live/apollo/server/src # sudo -u webstack -H bash -lc 'cd .../apollo/server/src && node index.js' # config: ecosystem + env file paths above; after env edit: sudo -u webstack pm2 restart "Apollo Solliquin Live" --update-env sudo -u webstack pm2 save # quick health after restart (brand url / local resolve patterns from cutover tooling) curl -s -o /dev/null -m20 -w '%{http_code}\n' https://www.solliquin.com/ curl -sk -o /dev/null -m20 -w '%{http_code}\n' --resolve www.solliquin.com:443:127.0.0.1 https://www.solliquin.com/ ---------------------------------------------------------------- 19) normal server-to-server file copy (standard reference examples — not from migration log) ---------------------------------------------------------------- # scp scp -i -P 22 local.file user@host:/remote/path/ scp -i -r localdir/ user@host:/remote/path/ scp -i user@host:/remote/file ./local.file # rsync common flags # dry-run first rsync -avzn --progress -e 'ssh -i -p 22' user@host:/remote/path/ ./localpath/ # real copy rsync -avz --progress -e 'ssh -i -p 22' user@host:/remote/path/ ./localpath/ # mirror (dangerous) — always dry-run with -n first rsync -avzn --delete -e 'ssh -i ' user@host:/remote/path/ ./localpath/ rsync -avz --delete -e 'ssh -i ' user@host:/remote/path/ ./localpath/ # excludes rsync -avz -e 'ssh -i ' --exclude node_modules --exclude .git --exclude '*.env' \ user@host:/home/webstack/solliquin.com/live/directus/uploads/ \ /backup/solliquin-directus-uploads/ # nice/ionice for big trees (as used in migration rsyncs) nice -n19 ionice -c3 rsync -avz -e 'ssh -i -o BatchMode=yes' user@host:/var/www/html/dir/ ./dir/ # preserve attrs when staying on one host cp -a --preserve=all /src/file /dst/file tar czf backup.tgz -C /src . tar xzf backup.tgz -C /dst ---------------------------------------------------------------- 20) normal search / replace (standard reference examples — not from migration log) ---------------------------------------------------------------- # grep grep -r 'needle' /var/www/html/mynutramax.com/stg/admin grep -rl 'needle' /var/www/html --include='*.php' grep -rn --include='*.php' --include='*.js' 'reset_password' /var/www/html/mynutramax.com grep -rn --exclude-dir=node_modules --exclude-dir=.git 'Directus' /home/webstack # find find /home/webstack -maxdepth 4 -type d -name directus find /var/www/html -type f -name '*.php' -mtime -7 find /root/backups -maxdepth 3 -name 'CHANGES.txt' find /home/webstack/solliquin.com -type f -name '.env' -exec ls -la {} \; # sed in-place with backup sed -i.bak 's/oldstring/newstring/g' file.php # then review: diff file.php.bak file.php # grep + sed combo grep -rl --include='*.php' 'oldstring' /path | xargs -r sed -i.bak 's/oldstring/newstring/g' # safer limited include grep -rl --include='*.js' 'professionals.reset.2' /var/www/html/mynutramax.com/stg/admin \ | xargs -r sed -i.bak 's#professionals.reset.2/submit.php#/admin/reset_password.php#g' # rg if installed (faster) rg -n --glob '*.php' 'nmx_dash_www' /var/www/html /etc/nmx ---------------------------------------------------------------- 21) Redis cache clear (WW7 local redis-server 127.0.0.1:6379) ---------------------------------------------------------------- # jbackus 20261024 - added redis cache clear commands # Password comes from /etc/redis/redis.conf (requirepass); don't paste it on the command line. # DBs in use: 0 als2 express-api, 1 Directus dev/stage + solliquin live, 2 denamarin live Directus, # 5 / 8 other node apps (REDIS_URL / REDIS in .env), 6 / 7 other caches. # maxmemory 1gb, allkeys-lru. Clearing a DB is safe for cache but drops sessions/rate limits stored there. # Shell helper (reads the password as root) rc() { sudo redis-cli --no-auth-warning -a "$(sudo awk '/^requirepass/{print $2}' /etc/redis/redis.conf)" "$@"; } # See what's in each DB first rc INFO keyspace rc -n 2 DBSIZE # Clear ONE database (preferred). Example: denamarin live Directus = DB 2 rc -n 2 FLUSHDB ASYNC # Clear only keys matching a pattern (e.g. Directus permissions cache) without touching the rest rc -n 2 --scan --pattern 'permissions:*' | xargs -r -n 500 sudo redis-cli --no-auth-warning \ -a "$(sudo awk '/^requirepass/{print $2}' /etc/redis/redis.conf)" -n 2 UNLINK # Clear EVERYTHING on the server (all DBs, all apps) - last resort rc FLUSHALL ASYNC # Directus alternative (clears its own cache via API, admin token required) curl -s -X POST -H 'Authorization: Bearer ' https:////utils/cache/clear # then restart the app if it still serves stale data sudo -u webstack pm2 restart ''