Lifesaver commands

This is just a personal notes of my daily work loads using PostgresSQL and Linux Server

Database backup and save it as compressed file

pg_dump -U [database_user] [database_name] | gzip -9 > [backup_file].sql.gz

Database restore using psql

Due its an easiest way and I’m kind of lazy to do it in a neat way:

psql -U [database_user] [database_target_name] < [backup_file_to_be_restored]

If you are trying to restore a compressed backup file, you must decompress it first. The command can be found at http://www.cyberciti.biz/howto/question/general/compress-file-unix-linux-cheat-sheet.php

File transfer using SCP

If you manage more than one server at a time, you must be familiar with this command. You can transfer files between your server directly.

scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]

That's it :fiuh: