PostgreSQL: Taking Backup of the Database
Taking Backup of Postgre Database using Console(windows)
To have a backup of the database
1. Enter the command Prompt
2. Move in to PostgreSQL’s bin folder.
3. type “pg_dump openbravodbase -U postgres > OBDbBackup123”. The OBDbBackup is the name of the backup file that will be created automatically created in bin folder of the Postgresql folder. Press enter.
4. A backup file will be created in the bin folder.
To restore the backup taken earlier,
1. Move to the PostgreSQL’s bin directory from the command prompt using ‘CD’ command.
2. Before that better clear the schema of the database by deleting all the tables of the database. Do it using the Posgre management tool PgAdmin. For that first select all the tables and the select the option Drop Cascaded. This way one by one delete tables, functions, triggers, operators, views etc. At time PGAdmin doesn’t let you delete the tables etc in such a case refresh the screen or restart PGAdmin.
3. Type “psql openbravodb -U username< backupDbnames ” in the command promp after copying the database backup file in the bin of PostgreSql Folder(this is where the postgre is installed).
To have a backup of the database
1. Enter the command Prompt
2. Move in to PostgreSQL’s bin folder.
3. type “pg_dump openbravodbase -U postgres > OBDbBackup123”. The OBDbBackup is the name of the backup file that will be created automatically created in bin folder of the Postgresql folder. Press enter.
4. A backup file will be created in the bin folder.
To restore the backup taken earlier,
1. Move to the PostgreSQL’s bin directory from the command prompt using ‘CD’ command.
2. Before that better clear the schema of the database by deleting all the tables of the database. Do it using the Posgre management tool PgAdmin. For that first select all the tables and the select the option Drop Cascaded. This way one by one delete tables, functions, triggers, operators, views etc. At time PGAdmin doesn’t let you delete the tables etc in such a case refresh the screen or restart PGAdmin.
3. Type “psql openbravodb -U username< backupDbnames ” in the command promp after copying the database backup file in the bin of PostgreSql Folder(this is where the postgre is installed).
Comments
Post a Comment