Backup and Restore Postgresql Database

create database:
[sourcecode language="bash"]
#create database from bash shell
su - postgres
bash-3.2$ createdb db_name;
bash-3.2$ dropdb db_name;
[/sourcecode]


Or you can go into database:
[sourcecode language="bash"]
#frm psql
#Connect as postgres to the postgres database
psql -d postgres postgres;
postgres=# create database new_db_name;
postgres=# drop database new_db_name;
[/sourcecode]


To backup a Postgresql Database:
[sourcecode language="bash"]
#bash shell
pg_dump -U db_user_name database_name -f backup_file_name.sql
[/sourcecode]


This command is to backup the database_name to file backup_file_name.sql.
To backup a specific schema of the database, use -n parameter
[sourcecode language="bash"]
#bash shell
pg_dump -U htang tripal_dev -n chado -f ~/DBBackups/tripal_dev__chado_only_20110901.sql
[/sourcecode]


To restore a backup from file use the follwing command:
[sourcecode language="bash"]
#bash shell
psql -f backup_file_path_and_name DATABASE_name;
#or you can
psql -d database_name < backup_file_path_and_name;
[/sourcecode]

Backup and Restore Postgresql Database

Part one:

create database:

$ su postgres

bash-3.2$ createdb db_name;

bash-3.2$ dropdb db_name;

Or you can go into database:

$ psql -d db_name;

db_name=# create database new_db_name;

db_name=# drop database new_db_name;



To backup a Postgresql Database:

$ pg_dump -U db_user_name database_name -f backup_file_name.sql

This command is to backup the database_name to file backup_file_name.sql.



To backup a specific schema of the database, use -n parameter

$ pg_dump -U htang tripal_dev -n chado -f ~/DBBackups/tripal_dev__chado_only_20110901.sql

To restore a backup file use the follwing command:

$ psql -f backup_file_path_and_name DATABASE_name;

  or you can

$ psql -d database_name < backup_file_path_and_name;

http://developer.postgresql.org/pgdocs/postgres/app-pgdump.html

How to use tar to backup files on CnetOS

>
command line
$ tar cvpzf backup_file_name.tgz path_to_the_file_you_want_to_back_up
'cvpfz' are the options we give to tar, like 'create archive' (obviously),
'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.
example
sudo tar cvpzf drupal.backup.tgz ./drupal/*

How to use tar to backup files on CnetOS

>
command line
$ tar cvpzf backup_file_name.tgz path_to_the_file_you_want_to_back_up
'cvpfz' are the options we give to tar, like 'create archive' (obviously),
'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.
example
sudo tar cvpzf drupal.backup.tgz ./drupal/*

Drupal and Imagecatch problem (Imagecache seems to work only if thefile system is set to private)


The problem is th epath to the image uploaded does not work correctly.
If you set the File system to Private under Administrator>>Files System, th epath problem is sovled. However this solution will affect other Drupal Modules.
I have tried other ways :
  1. set the permission for pth "/var/www/drupal/sites/default" to 777----doe snot work.
  2. change the content of .htaccess---doe snot work
The following seems a coorect way to do so:
"Changed case FILE_DOWNLOADS_PUBLIC to be the same as case FILE_DOWNLOADS_PRIVATE and Voila: It worked!. I am now thinking that this must be a path issue of some sort? Assuming that this is the case, I'm changing the status on this to bug report. Correct me if I'm being premature (or just wrong)."

Source:
  • http://drupal.org/node/399790#comment-1428428
  • http://drupal.org/node/366177

Drupal and Imagecatch problem (Imagecache seems to work only if thefile system is set to private)


The problem is th epath to the image uploaded does not work correctly.
If you set the File system to Private under Administrator>>Files System, th epath problem is sovled. However this solution will affect other Drupal Modules.
I have tried other ways :
  1. set the permission for pth "/var/www/drupal/sites/default" to 777----doe snot work.
  2. change the content of .htaccess---doe snot work
The following seems a coorect way to do so:
"Changed case FILE_DOWNLOADS_PUBLIC to be the same as case FILE_DOWNLOADS_PRIVATE and Voila: It worked!. I am now thinking that this must be a path issue of some sort? Assuming that this is the case, I'm changing the status on this to bug report. Correct me if I'm being premature (or just wrong)."

Source:
  • http://drupal.org/node/399790#comment-1428428
  • http://drupal.org/node/366177

Configure Screen Resolution of CentOS on VM Ware

>
command line
$ sudo system-config-display
will pop out the configuration window. You can configure here to adjust the screen resolution.
Or you can set up all of them through the command line:
$ sudo system-config-display --reconfigure -set-depth=24 --set-resolution=1920x1080 --set-driver=vmware

It does not work on my machine, but I found that it does work many other people's machine. Let me know if you have other solution may work it out for me.

Configure Screen Resolution of CentOS on VM Ware

>
command line
$ sudo system-config-display
will pop out the configuration window. You can configure here to adjust the screen resolution.
Or you can set up all of them through the command line:
$ sudo system-config-display --reconfigure -set-depth=24 --set-resolution=1920x1080 --set-driver=vmware

It does not work on my machine, but I found that it does work many other people's machine. Let me know if you have other solution may work it out for me.

How to set up your CentOS path?

>
There are two places you can set up you PATH on CentOS.
1.  set up in ~/.bash_profile which is executed for login shells (You have to reboot your machine to make the change take effect).
2. set up in ~/.bashrc which is executed for interactive non-login shells. (You do not need to reboot to make the change take effects. Just need to open a new termial)

How to set up your CentOS path?

>
There are two places you can set up you PATH on CentOS.
1.  set up in ~/.bash_profile which is executed for login shells (You have to reboot your machine to make the change take effect).
2. set up in ~/.bashrc which is executed for interactive non-login shells. (You do not need to reboot to make the change take effects. Just need to open a new termial)

Test ScribeFire the new tool to publish your blog

Discovered a new tool to publish your blog: ScribeFire.

Test ScribeFire the new tool to publish your blog
Hello World

Test ScribeFire the new tool to publish your blog

Discovered a new tool to publish your blog: ScribeFire.

Test ScribeFire the new tool to publish your blog
Hello World

set PATH in CentOS

>export PATH=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/:$PATH

set PATH in CentOS

>export PATH=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/:$PATH

Mount Samba Netdrive in CentOS

1. ping machine_name to check whether the machine is available or not.
2. smbclient machine_name -U user_name to check whether the machine is using samba
3. get the path of sharing folder from windows xp machine
4. sudo mount -t cifs -o user=user_name //path got from windows xp machine /mnt/mnt_point/

** You have to re-mount every time you reboot your system.

Mount Samba Netdrive in CentOS

1. ping machine_name to check whether the machine is available or not.
2. smbclient machine_name -U user_name to check whether the machine is using samba
3. get the path of sharing folder from windows xp machine
4. sudo mount -t cifs -o user=user_name //path got from windows xp machine /mnt/mnt_point/

** You have to re-mount every time you reboot your system.

Set PostGreSQL to accept remote access

Step # 1: Enable client authentication

Edit the PostgreSQL configuration file /var/lib/pgsql/data/pg_hba.conf:

# TYPE DATABASE USER CIDR-ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 10.14.0.0/0 password
# IPv6 local connections:
host all all ::1/128 password

Save and close the file.

Step # 2: Enable networking for PostgreSQL: Allow TCP/IP socket

If you are using PostgreSQL version 8.x or newer use the following instructions or skip to Step # 3a for older version (7.x or older).

You need to open PostgreSQL configuration file /var/lib/pgsql/data/postgresql.conf

In this file change the following:

listen_addresses='localhost'

to

listen_addresses='*'

Step # 3 Restart PostgreSQL Server

Type the following command:
# /etc/init.d/postgresql restart

Step # 4: Iptables firewall rules

Make sure iptables is not blocking communication, open port 5432 (append rules to your iptables scripts or file /etc/sysconfig/iptables):

put this line in the iptables,

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

But it must before this line,

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

Restart firewall:
# /etc/init.d/iptables restart
Step # 6: Test your setup

Modified from http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html

**Try to disable the Iptable if you still can not work it out.

Install PostgreSQL V9.x on Centos

1. Configure your YUM repository Since there is no v9.x in yum repository at the time of writing, you could not use yum to intall postgres without reconfiguration of yum repository. In order to do so: Edit /etc/yum.repos.d/CentOS-Base.repo, add the following lines to both [base] and [updates] sections exclude=postgresql* Then you need download and install PGDG RPM file for for your version of the CentOS from here. Here is the link for 64 Bit version of CentOS.
wget http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/pgdg-centos92-9.2-6.noarch.rpm
rpm -ivh pgdg-centos92-9.2-6.noarch.rpm
2. Install postgreSQL After these modifications you could use yum to install postgreSQl versino 9.2. I installed both postgresql-server and postgresql-devel
yum install postgresql-server postgresql-devel
3. Post-installation configuration 3.1. Initialize The first command (only needed once) is to initialize the database in PGDATA:
/sbin/service postgres-9.2 initdb
3.2. Startup
/etc/init.d/postgresql-9.2 start
If you want PostgreSQL to start automatically when CentOS starts:
/sbin/chkconfig postgresql-9.2 on
3.3.Set PostgreSQL 9 Environment The deault home directory for the user postgres is at /var/lib/pgsql The bash_profile for the user postgres will look like this:
[ -f /etc/profile ] && source /etc/profile
PGDATA=/var/lib/pgsql/9.2/data
export PGDATA
This contains a path for the data directory, but no path for the executable/binary directory. To ammend this, add the path as below:
[ -f /etc/profile ] && source /etc/profile
PGDATA=/var/lib/pgsql/9.2/data
export PGDATA
PATH=$PATH:$HOME/bin:/usr/pgsql-9.2/bin
export PATH
Placing the binary directory in the path for postgres will allow you to invoke pg_ctl and other commands from the shell. 3.4. Add User The superuser postgres has no password set by default. To set the password, switch to postgres user:
# Linux environment
sudo su -
passwd postgres
# follow the screen to supply the new password for postgres
Connect to postgres database as user postgres.
psql postgres postgres
postgres=#
postgres=# create user myuser with password 'secret';
if you forget to assign a password to new use, you could do it by going to the database environment:
#postgresql environment
alter user user_name with password='new_password'
3.5. Create a database and give ownership to the new user:
postgres=# create database mytestdb owner=myuser;
Connect to the database as new user:
postgres=# \c mytestdb myuser
Password for user myuser:
You are now connected to database "mytestdb" as user "myuser".
3.6. Other configurations Modifications to the configure file to allow postgresql accept local/remote access Step # 1: Enable client authentication Edit the PostgreSQL configuration file /var/lib/pgsql/9.2/data/pg_hba.conf:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 10.14.0.0/0 password
# IPv6 local connections:
host all all ::1/128 password
# Save and close the file. In order for the change to take effect, reload the pg_hba.conf file.
su - postgres
pg_ctl reload
Step # 2: Enable networking for PostgreSQL: Allow TCP/IP socket If you are using PostgreSQL version 8.x or newer use the following instructions: Open PostgreSQL configuration file /var/lib/pgsql/9.2/data/postgresql.conf and change
listen_addresses='localhost'
to
listen_addresses='*'
Step # 3 Restart PostgreSQL Server
/etc/init.d/postgresql-9.2 restart
Step # 4: Modify Iptables firewall rules Make sure iptables is not blocking communication, open port 5432 (append rules to your iptables scripts or file /etc/sysconfig/iptables): put this line in the iptables,
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
But it must before this line,
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
Restart firewall:
/etc/init.d/iptables restart
All set.

How to disable suexec in CentOS

1. locate where is suexec by running the following:

whereis suexec

return
suexec: /usr/sbin/suexec /usr/share/man/man8/suexec.8.gz

2. rename the suexec to suexec_old
mv /usr/sbin/suexec /usr/sbin/suexec_old

3. restart httpd
sudo /etc/init.d/httpd restart

How to disable suexec in CentOS

1. locate where is suexec by running the following:

whereis suexec

return
suexec: /usr/sbin/suexec /usr/share/man/man8/suexec.8.gz

2. rename the suexec to suexec_old
mv /usr/sbin/suexec /usr/sbin/suexec_old

3. restart httpd
sudo /etc/init.d/httpd restart

Install Subversion on CentOS

1. Install subversion

$(sudo) yum install mod_dav_svn subversion

2. check functions provide by the svn:
$ svn --help

2. make a local directory to hold the content checked out from the repository
$ mkdir ~/repository

3.Go to the newly made directory and check out the content you want from the internet
$ cd ~/repository
$ svn co URL_to_Content_on_Internet

credit to : http://wiki.centos.org/HowTos/Subversion

Install Subversion on CentOS

1. Install subversion

$(sudo) yum install mod_dav_svn subversion

2. check functions provide by the svn:
$ svn --help

2. make a local directory to hold the content checked out from the repository
$ mkdir ~/repository

3.Go to the newly made directory and check out the content you want from the internet
$ cd ~/repository
$ svn co URL_to_Content_on_Internet

credit to : http://wiki.centos.org/HowTos/Subversion

Install perl TimeDate and DateManip modules in CentOS

The command used to install the TimeDate module is:
$(sudo) yum install perl-TimeDate

The command used to install the DateManip module is:
$(sudo) yum install perl-DateManip

There is no support installation throught CPAN yet.

Install perl TimeDate and DateManip modules in CentOS

The command used to install the TimeDate module is:
$(sudo) yum install perl-TimeDate

The command used to install the DateManip module is:
$(sudo) yum install perl-DateManip

There is no support installation throught CPAN yet.

How to reset your password in Ubuntu

1. Boot into Safe mood of Ubuntu by holding either shift or ESC key.
a. (Ubuntu is the only operating system on your computer), to get the boot menu to show, you have to hold down the Shift key during bootup.
b. For older versions of Ubuntu (9.04 and 8.04), you can press the Escape key during bootup in order to see the boot menu.

2. Select "Drop to root shell prompt option" to go to root shell.
3. ls /home will show all the current users in your Ubuntu.
4. passwd username to change username's password.
5. type "exit" to exit root shell.

How to reset your password in Ubuntu

1. Boot into Safe mood of Ubuntu by holding either shift or ESC key.
a. (Ubuntu is the only operating system on your computer), to get the boot menu to show, you have to hold down the Shift key during bootup.
b. For older versions of Ubuntu (9.04 and 8.04), you can press the Escape key during bootup in order to see the boot menu.

2. Select "Drop to root shell prompt option" to go to root shell.
3. ls /home will show all the current users in your Ubuntu.
4. passwd username to change username's password.
5. type "exit" to exit root shell.

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...