Backup:
- pg_dump -U username -W database_name -h host_address > /path/back_file_name.sql
- when prompted, enter the db password for the db user desknowserver (ex. 'password')
- the command will generate a file called /var/back_file_name.sql - if you need to store this file, it is recommended to compress it with gzip, as this will greatly reduce its size
pg_dump -U username -W database_name -h host_address | gzip > /path/back_file_name.sql
ex. sudo pg_dump -U postgres -W testdb -h localhost | gzip > /home/cheer/testdb.sql
Restore:
recreate the desknow (or use another name) database following the standard procedure:
- su - postgres
- psql template1 desknowserver
- create database desknow with encoding='UNICODE';
- \c desknow desknowserver
- \i /var/desknowbackup.sql