1.2.1 • Published 1 year ago

henrybuilt-cli v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Usage

hb <sub-command> [options]

Available subcommands

  • db-sync (Dumps production database and imports it into local database)
  • db-backup (Dumps production database and saves it to S3)
  • pt-backup-proposals (Backs up proposal pdfs for all PT Project Versions to S3)
  • audit-s3-file-permissions (Verifies client files are not publicly available)
  • hb db-sync -t staging (Dumps production database and imports it into staging database)

Usage

Initial setup

  1. cd ~
  2. git clone https://github.com/henrybuilt/henrybuilt-cli.git
  3. cd into henrybuilt-cli
  4. sudo npm install -g
  5. Place your env file at ~/hb.env (ask for a .env file if you don't have one)
  6. Run hb db-sync to test.
    • If there is an authentication error, run ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; in your mysql client

Updating

  1. cd into henrybuilt-cli
  2. git pull
  3. sudo npm install -g (if this doesn't work, sudo apt-get install npm)

Developing

  1. Pull
  2. Check out a branch
  3. Make modifications
  4. Verify script works as expected - e.g. node ./src/hb.js db-sync -t staging
  5. Bump version number

If you want to be able to run all commands, you need:

  • ~/hb.env file
  • mysql command/binary

The following are required to run each command:

  • pt-backup-proposals
    • env
      • HB_PRODUCTION_DB_HOST, HB_PRODUCTION_DB_USER, HB_PRODUCTION_DB_PASSWORD, HB_PRODUCTION_DB_DATABASE
      • HB_ADMIN_ACCESS_KEY
      • if you want to backup to s3 AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  • db-sync
    • mysql command
    • mysqldump command
    • env
      • HB_PRODUCTION_DB_HOST, HB_PRODUCTION_DB_USER, HB_PRODUCTION_DB_PASSWORD, HB_PRODUCTION_DB_DATABASE
      • if your local mysql server has a non-empty password HB_DEVELOPMENT_DB_PASSWORD
    • if you want to sync faster, you can place aws-remote-backup.pem in home directory and include AWS_REMOTE_IP in env file
  • db-backup
    • mysql command
    • mysqldump command
    • env
      • HB_PRODUCTION_DB_HOST, HB_PRODUCTION_DB_USER, HB_PRODUCTION_DB_PASSWORD, HB_PRODUCTION_DB_DATABASE
      • AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  • wf-db-backup
    • ~/.pgpass file with correct permissions: chmod 0600 ~/.pgpass
    • pg_dump command - brew install postgresql@11
    • normal error output you can ignore that we didn't have time to fix:
      • SQL errors (~100 lines)
      • at checkExecSyncError (child_process.js:601:13)
    • use --skip when repeatedly syncing for faster syncs (skips download step)

The following commands have no prerequisites:

  • audit-s3-file-permissions

Usage

  • wf-backup-db
    • To restore from a compressed backup: pg_restore -Fc -h <host> -U <user> -d <db> < 2018-03-23_18-11-02.compressed
    • To restore from a SQL backup: pg_restore -h <host> -U <user> -d <db> < 2018-03-23_18-11-02.sql

TODO

  • macos notifications when complete
  • hb audit-website-permissions - arrays of links that are supposed to (in)accessible, pt api, admin, client site other users
  • hb de-backup-order-summaries
  • hb check-system-status
  • hb load-test ?
  • log time
  • backup to external service outside aws
  • audit document visibility, component icon visibility