Skip to content

Instantly share code, notes, and snippets.

@UlisesGascon
Created August 20, 2020 06:06
Show Gist options
  • Save UlisesGascon/78642e01b9db0e15f4f8d5d13ac3aa84 to your computer and use it in GitHub Desktop.
Save UlisesGascon/78642e01b9db0e15f4f8d5d13ac3aa84 to your computer and use it in GitHub Desktop.
Dump, compare and check db integrity

Database Backup and comparation

Dump Postgres DB

pg_dump --data-only --inserts -h <DB_URL> -U <DB_USER> -f <FILE_NAME_TO_CREATE.sql> <DB_NAME>

Notes:

  • --data-only will dump only data to be inserted (not tables strcuture and relations)
  • --inserts will force to use INSERT statements and not COPY to avoid driver issues later on

Generate dump hash

shasum -a 256 <FILE_NAME>

Compare differences

Old school way

diff <file_1> <file_2>

Fancy way (preview in VSCode)

code --diff <file_1> <file_2>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment