Copy Paste PostgreSQL Beserta Datanya
#!/bin/bash ##copy_schema.sh dbusername="$1" dbname="$2" from_schema="$3" to_schema="$4" pg_dump -U "$from_schema" -h localhost -W --schema="$from_schema" "$dbname" | sed "s/$from_schema/$to_schema/g" > "$to_schema".sql echo "\i "$to_schema".sql" | psql -v ON_ERROR_STOP=1 -U "$to_schema" -d "$dbname" -h localhost -W
Copy Paste PostgreSQL Strukturnya Saja
#!/bin/bash ##copy_schema.sh dbusername="$1" dbname="$2" from_schema="$3" to_schema="$4" pg_dump -U "$from_schema" -h localhost -W --schema-only --schema="$from_schema" "$dbname" | sed "s/$from_schema/$to_schema/g" > "$to_schema".sql echo "\i "$to_schema".sql" | psql -v ON_ERROR_STOP=1 -U "$to_schema" -d "$dbname" -h localhost -W
Cara menggunakan : ./copy_schema.sh username nama_schema_lama nama_schema_baru
No comments:
Post a Comment