For the restoring the database if you don't know the file type then you need to follow the below command to check the database file type.
>> file database_file_name
For Example:
>> file live_db.dump
Based on the file type we have different commands for restore the each database file type.
>> file database_file_name
For Example:
>> file live_db.dump
Based on the file type we have different commands for restore the each database file type.
Restoring the database using psql file type:
1.First we need to create a new database in our system.
1.First we need to create a new database in our system.
>> createdb database_name --encoding=UNICODE
For Example:
>> createdb my_project_live --encoding=UNICODE
2.Now we need to import the old database to our new database
>>psql new_database_name < old_database_name
For Example:
>> psql my_project_live < live_db_backup.psql
Restoring the database using dump file type:
1.For the restore the dump database in our system we need to follow the below command :
>>DB= new_database_name && createdb --cluster 9.1/main $DB && pg_restore --cluster 9.1/main --no-acl -O -d $DB < backup_database_file_name
For Example:
>>DB=live_project_db && createdb --cluster 9.1/main $DB && pg_restore --cluster 9.1/main --no-acl -O -d $DB < remote_dump_file.dump
Restoring the database using zip file type:
1.First we need to create a new database in our system.
>> createdb new_database_name --encoding=UNICODE
For Example:
>> createdb my_project_live --encoding=UNICODE
2.Now we need to uncompress the zip file and import the backup database.
>>gunzip < backup_db_zip_file | psql -U <postgresql user name/same name as for system user name> new_database_name
For Example:
>> gunzip < backup_database.zip | psql -U maze2innovation my_project_live