Many times I have to run data refresh between Production to Development to unload and load data for testing,development SIT and UAT. There are two methods which I used. First option is nzsql and nzload. Second is nz_migrate which is the easiest and most flexible.
nzsql -u <USERNAME> -pw <PASSWORD> -d <DATABASE> -host <HOSTNAME> -A -t -F{ -f <SQL_FILE>.sql -o <SQL_OUTPUT>.dat
-A - Unaligned table output mode (-P format=unaligned)
-t - Print rows only (-P tuples_only)
-F - delimiter
nzload -host <HOSTNAME> -db <DATABASE> -u <USERNAME> -pw <PASSWORD> -t <TABLE_NAME> -df <SQL_OUTPUT>.dat -delim "{" -dateDelim "-" -dateStyle "YMD" -nullValue ''
nz_migrate
The command can be run either from source or target host. Make sure the parameter value is correct. Otherwise, you will be overwriting your Production source.
nz_migrate -shost <SOURCE_HOST> -thost <TARGET_HOST>
-sdb <SOURCE_DATABASE>
-tdb <TARGET_DATABASE>
-stable <SOURCE_TABLE>
-ttable <TARGET_TABLE>
-suser <SOURCE_USERNAME> -spassword <SOURCE_PASSWORD>
-tuser <TARGET_USERNAME> -tpassword <TARGET_PASSWORD>
-CreateTargetTable y -TruncateTargetTable n CreateTargetDatabase n -threads 4
No comments:
Post a Comment