Skip to content

Instantly share code, notes, and snippets.

@yiidtw
Last active August 16, 2019 09:13
Show Gist options
  • Save yiidtw/4824eb49dbbce09d14530eaf13284fb6 to your computer and use it in GitHub Desktop.
Save yiidtw/4824eb49dbbce09d14530eaf13284fb6 to your computer and use it in GitHub Desktop.
snippet for pg and es migration
pg_dump -h db_host -U user_name -p 5432 -F c -v -f /path/to/backup/data.bak db_name
pg_restore -v -h db_host -p 5432 -U user_name -d db_name /path/to/backup/data.bak
curl -X GET 'http://localhost:9200/_cat/indices?v'
# dump
elasticdump --input=http://localhost:9200/index_name --output=/path/to/backup/data.json --type=data
# restore
elasticdump --input=/tmp/aa.aisoc/ds_as.json --output=http://localhost:9200 --type=data --headers='{"content-type": "application/json"}'
mkdir -p es_backup
multielasticdump --direction=dump --input=http://localhost:9200 --output=es_backup
multielasticdump --direction=load --input=es_backup --output=http://localhost:9200
tar zcvf - dir_to_transfer | ssh remote_host "cd /tmp; tar zxvf -"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment