Events Calendar

September 2010
M T W T F S S
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3

Select Language

Proof of concept (PostgreSQL) PDF Print E-mail
Written by repostor   
Monday, 21 December 2009 22:36

1) Create a script which load data to a database.

------------- Windows ----------------


C:\> notepad insert.bat

echo "create database test;|psql -U postgres"
set /p enter="press enter"

echo "create database test;"|psql -U postgres

echo "create table test (tid timestamp);|psql -U postgres test"
set /p enter="press enter"
echo "create table test (tid timestamp);"|psql -U postgres test

:forever
echo "insert into test (tid) values (now());|psql -U postgres test"
echo "insert into test (tid) values (now());"|psql -U postgres test
@ping 127.0.0.1 -n 2 -w 1000 > nul
goto forever

 

--------- UNIX / Linux ---------

# vi insert.sh

 

#!/bin/ksh

echo "create database test;|psql -U postgres"
read enter

echo "create database test;"|psql -U postgres

echo "create table test (tid timestamp);|psql -U postgres test"
read enter
echo "create table test (tid timestamp);"|psql -U postgres test

while [ 1 ]

do

echo "insert into test (tid) values (now());|psql -U postgres test"
echo "insert into test (tid) values (now());"|psql -U postgres test
sleep 1


done

2) Run the script

--- Windows ---

C:\> insert.bat

--------- UNIX / Linux ---------

# chmod 777 insert.sh

# ./insert.sh

3) Do a full backup

--- Windows ---

C:\Program Files\repostor\Data Protector for PostgreSQL\bin> postgreslbackup -u postgres -f

--------- UNIX / Linux ---------

# /opt/repostor/rdp4PostgreSQL/bin/postgresbackup -u postgres -f

 

4) Do an incremental backup

--- Windows ---

N/A (all the logs are switched automatically)

You can force a logswitch manaully:

C:\> psql -U postgres

psql# SELECT pg_start_backup('label');

psql# SELECT pg_stop_backup();

psql# \q

--------- UNIX / Linux ---------

N/A (all the logs are switched automatically)

You can force a logswitch manaully:

# psql -U postgres

psql# SELECT pg_start_backup('label');

psql# SELECT pg_stop_backup();

psq#\q

6) Terminate the "insert.bat" / "insert.sh" script

7) Do an incremental backup

N/A

--------- UNIX / Linux ---------

N/A

8) Verify content of the "test" table, in test database

echo select * from test;|psql -U postgres test

tid

2009-09-08 14:26:06
2009-09-08 14:26:07
2009-09-08 14:26:08
..
2009-11-25 19:11:26

9) Drop instance

C:\> del "C:\Program Files\PostgreSQL\8.3\data"

# rm /var/lib/postgres/data

10) Restore test database from backup

Kör kommandot:

--- Windows ---

C:\Program Files\repostor\Data Protector for PostgreSQL\bin> postgresrestore -u postgres -f -v -t YYYY-MM-DD.HH:MM:SS

--------- UNIX / Linux ---------

# /opt/repostor/rdp4PostgreSQL/bin/postgresrestore -v -f -t YYYY-MM-DD.HH:MM:SS

Där YYYY-MM-DD.HH:MM:SS är någon av datum / tiderna ur listan ovan

Tex;

C:\Program Files\repostor\Data Protector for PostgreSQL\bin> poestgresrestore -u postgres -f -v -t 2009-11-25.19:11:27

10) Start instance

C:\> net start "PostgreSQL 8.3"

# /etc/init.d/postgres start

11) Verify content of test table in test database

echo select * from test;|psql -U postgres test

 

Last Updated on Friday, 27 August 2010 18:20
 
Repostor : Your recovery expert