Friday, July 15, 2011

Running TeamViewer 5/6 as root on Linux | Fedora | Ubuntu | RHEL | CentOS


First of all Let me tell you that this HOWTO is performed on Fedora Ubuntu Red Hat Enterprise Linux and CentOS. This post is applied for TeamViewer Version 5 and 6.
Here is the post on TeamViewer on Linux Again. Hoping that you guys enjoyed previous post regarding TeamViewer Installing on Linux.
Now Here I am going to post 1 trick and tips for TeamViewer. Many Users who likes to work as root and but in TeamViewer 5 there is restriction for Running as root.
Whenever you are trying to run TeamViewer as root from Terminal, You will get message like below :-
TeamViewer must not be executed as root!
By Following very few steps you will be able to run TeamViewer as root.
Perform Following Steps to run TeamViewer As root.
  1. Of Course you have to be root to perform these all steps.
  2. Please Open Terminal on Fedora, Red Hat, CentOS ( Applications -> System Tools -> Terminal )
    Please Open Terminal on Ubuntu ( Applications -> Accessories -> Terminal )
  3. Now Lets find where exactly teamviewer command is. Execute Following command to Find it out.
    [root@ask4itsolutions.com]# which teamviewer
    /usr/bin/teamviewer 
    <– You will get this kind of output on your terminal
  4. Be safe So First Lets take a backup of Original TeamViewer Command. Execute Following Command
    cp /usr/bin/teamviewer /usr/bin/teamviewer-orig
  5. Let’s Open teamviewer file. Here in /usr/bin/teamviewer they have put the restriction for root user. So Lets Remove it. Open File By Executing vim /usr/bin/teamviewer and You will able to see following lines into /usr/bin/teamviewer :-
    userid=$(id -u)
    if [ $userid = 0 ]
    then
    echo TeamViewer must not be executed as root!
    exit 1
    fi

    CHANGE those line to
    ##userid=$(id -u)
    ##if [ $userid = 0 ]
    ##then
    ##        echo TeamViewer must not be executed as root!
    ##        exit 1
    ##fi

    Save and Exit this file ( Press “ESC” then Press :wq! )
  6. To Open TeamViewer from GUI. Click on Applications -> Internet -> TeamViewer
  7. To Open TeamViewer from Terminal in Fedora, Red Hat and CentOS. Click on Applications -> System Tools -> Terminal. On Terminal Execute Command teamviewerTo Open TeamViewer from Terminal in Ubuntu. Click on Applications -> Accessories -> Terminal. On Terminal Execute Command teamviewer
  8. That’s It Guys
Hope you all like this tip about Running TeamViewer as root on Fedora, Ubuntu, CentOS and RHEL. Please let me know if you face any difficulties while performing above steps. I have not tested it on Ubuntu but it should work with same way.

Thursday, July 14, 2011

Teclast tPad T760 WIFI 8GB 7" Android 2.3 [My Tablet PC]

ProcessorARM Cortex A8 RK2918 1.2Ghz ,Vivante GC800 GPU
RAM512MB DDR III + 512MB ROM
Memory8GB , Support Micro SD Card to 32GB 
Screen7 inch capacitive touch-screen  LCD 1024*600 Virtual keyboard 5 points touching
WirelessOn-board wireless 802.11b/g module
 OSAndroid 2.3 OS ,Support Original Flash 10.1 , over 30,0000 software
AudioMP3 , WMA , WAV , APE , FLAC , AAC Speaker, Microphone 3.5mm (stereo) headset jack
Video1080P, AVI / MOV / MP4 / RMVB / FLV / MKV
Camera2 Mega Pixel Back Camera, 0.3 Camera Front Camera
LanguageMultilanguage (Android 2.3 ) 
Battery2500mAh battery
FeaturesAndroid Market , Office Suite , word , pdf , excel , PDF ,Google Gmail , website browser , youtube , flash 10.1 , online flash video  ,   super fast android 2.3 os , 3D game , g-sensor game  ,  multitouching, G-Sensor, HDMI Interface
Package includeUSB Cable , Earphone , DC Charger

Indian Government online.. :)

The national portal of India launched by Indian Government gives all the info required to get most important documents. It a great effort of putting all the process at one place.
Take a look at http://www.india.gov.in/ 
************************************************************
Indian Government Online!! - Really Marvelous Effort 
cid:image001.jpg@01CB3A16.5C8A4C50
Obtain:
1. Birth Certificate < http://www.india.gov.in/howdo/howdoi.php?service=1 > . 
2. 
Caste Certificate < http://www.india.gov.in/howdo/howdoi.php?service=4 > . 
3. 
Tribe Certificate < http://www.india.gov.in/howdo/otherservice_details.php?service=8 > . 
4. 
Domicile Certificate < http://www.india.gov.in/howdo/howdoi.php?service=5 > . 
5. 
Driving Licence < http://www.india.gov.in/howdo/howdoi.php?service=6 > . 
6. 
Marriage Certificate < http://www.india.gov.in/howdo/howdoi.php?service=3 > . 
7. 
Death Certificate < http://www.india.gov.in/howdo/howdoi.php?service=2 > .
Apply for: 
1. PAN Card < http://www.india.gov.in/howdo/otherservice_details.php?service=15 > . 
2. 
TAN Card < http://www.india.gov.in/howdo/otherservice_details.php?service=3 > . 
3. 
Ration Card < http://www.india.gov.in/howdo/howdoi.php?service=7 > . 
4. 
Passport < http://www.india.gov.in/howdo/otherservice_details.php?service=2 > . 
5. 
Inclusion of name in the Electoral Rolls < http://www.india.gov.in/howdo/howdoi.php?service=10 > .
Register: 
1. Land/Property < http://www.india.gov.in/howdo/howdoi.php?service=9 > . 
2. 
Vehicle < http://www.india.gov.in/howdo/howdoi.php?service=13 > . 
3. 
With State Employment Exchange < http://www.india.gov.in/howdo/howdoi.php?service=12 > . 
4. 
As Employer < http://www.india.gov.in/howdo/otherservice_details.php?service=17 > . 
5. 
Company < http://www.india.gov.in/howdo/otherservice_details.php?service=19 > . 
6. 
.IN Domain < http://www.india.gov.in/howdo/otherservice_details.php?service=18 > . 
7. 
GOV.IN Domain < http://www.india.gov.in/howdo/otherservice_details.php?service=25 > .

Check/Track:
1. Waiting list status for Central Government Housing < http://www.india.gov.in/howdo/otherservice_details.php?service=9 > . 
2. 
Status of Stolen Vehicles < http://www.india.gov.in/howdo/otherservice_details.php?service=1 > . 
3. 
Land Records < http://www.india.gov.in/landrecords/index.php > . 
4. 
Cause list of Indian Courts < http://www.india.gov.in/howdo/otherservice_details.php?service=7 > . 
5. 
Court Judgments (JUDIS ) < http://www.india.gov.in/howdo/otherservice_details.php?service=24 > . 
6. 
Daily Court Orders/Case Status < http://www.india.gov.in/howdo/otherservice_details.php?service=21 > . 
7. 
Acts of Indian Parliament < http://www.india.gov.in/howdo/otherservice_details.php?service=13 > . 
8. 
Exam Results < http://www.india.gov.in/howdo/otherservice_details.php?service=16 > . 
9. 
Speed Post Status < http://www.india.gov.in/howdo/otherservice_details.php?service=10 > . 
10. 
Agricultural Market Prices Online < http://www.india.gov.in/howdo/otherservice_details.php?service=6 > .
Book/File/Lodge: 
1. Train Tickets Online < http://www.india.gov.in/howdo/otherservice_details.php?service=5 > . 
2. Air Tickets Online < 
http://www.india.gov.in/howdo/otherservice_details.php?service=4 > . 
3. Income Tax Returns < 
http://www.india.gov.in/howdo/otherservice_details.php?service=12 > . 
4. Complaint with Central Vigilance Commission (CVC) < 
http://www.india.gov.in/howdo/otherservice_details.php?service=14 > .
Contribute to: 
1. Prime Minister's Relief Fund < http://www.india.gov.in/howdo/otherservice_details.php?service=11 > . 
Others: 

1. Send Letters Electronically < http://www.india.gov.in/howdo/otherservice_details.php?service=20 > . 
Recently Added Online Services 

1. Tamil Nadu: Online application of marriage certificate for persons having registered their marriages

 < http://www.india.gov.in/howdo/onlineservice_detail.php?service=2691 > . 
2. Tamil Nadu: Online District wise soil Details of Tamil Nadu < http://www.india.gov.in/howdo/onlineservice_detail.php?service=2693 > . 
3. Tamil Nadu: View Water shed Atlas of Tamil Nadu < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2694 > . 
4. Tamil Nadu: E-Pension District Treasury Tirunelveli < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2695 > . 
5. Meghalaya: Search Electoral Roll Online by Name (2008) < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2697 > . 
6. Meghalaya: Search Electoral Roll Online by EPIC number (2008) < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2698 > . 
7. Meghalaya: Search Electoral Roll Online by House number (2008) < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2699 > . 
8. Himachal Pradesh: Revised Pay and Arrears Calculator-Fifth Pay < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2702 > . 
9. Meghalaya: Search Electoral Roll Online by Part number (2008) < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2700 > . 
10. Andhra Pradesh: Online Motor Driving School Information < 
http://www.india.gov.in/howdo/onlineservice_detail.php?service=2705 > .
Global Navigation 
1. Citizens < http://www.india.gov.in/citizen.php > . 
2. Business (External website that opens in a new window) < 
http://business.gov.in/ > . 
3. Overseas < 
http://www.india.gov.in/overseas.php > . 
4. Government < http://www.india.gov.in/govt.php > . 
5. Know India < 
http://www.india.gov.in/knowindia.php > . 
6. Sectors < http://www.india.gov.in/sector.php > . 
7. Directories < 
http://www.india.gov.in/directories.php > . 
8. Documents < 
http://www.india.gov.in/documents.php > . 
9. Forms < http://www.india.gov.in/forms/forms.php > . 
10. Acts < 
http://www.india.gov.in/govt/acts.php > . 
11. Rules < http://www.india.gov.in/govt/rules.php > . 
12. Schemes < 
http://www.india.gov.in/govt/schemes.php > . 
13. Tenders < 
http://www.india.gov.in/tenders.php > . 
14. Home < http://www.india.gov.in/defaultphp > . 
15. About the Portal < 
http://www.india.gov.in/abouttheportal.php > . 
16. Site Map < 
http://www.india.gov.in/sitemap.php > . 
17. Link to Us < http://www.india.gov.in/linktous.php > . 
18. Suggest to a Friend < 
http://www.india.gov.in/suggest/suggest.php > . 
19. Help < 
http://www.india.gov.in/help.php > . 
20. Terms of Use < http://www.india.gov.in/termscondtions.php > . 
21. Feedback < 
http://www.india.gov.in/feedback.php > . 
22. Contact Us < http://www.india.gov.in/contactus.php > .
23. Accessibility Statement < http://www.india.gov.in/accessibilitystatement.php >

Wednesday, July 13, 2011

Access your accounts(Gmail/Facebook.. etc.,)as diff users on the same web browser

Run the Firefox Profile Manager
$ firefox -no-remote -P
After executing this command, you ‘ll see a pop-up window.
Click on create profile button and add your profile name.
Clich the “Start Firefox” button. That’s all. :)
For Example, before executing the above command, login to your gmail/facebook or any other site.
Now after clicking the ‘Start Firefox’ command by executing the above command, you can login to those sites as a different user( two or more users )on the same web browser.
So, there is no restriction that the user has to logout to give access to another user. ;)

Tuesday, July 12, 2011

PostgreSQL for the sage – Must know basics for the system administrators

PostgreSQL or Postgres is an object-relational database management system (ORDBMS). Unlike MySQL, PostgreSQL is not controlled by any single company, it is a community developed project. It is a advanced version of the ‘Ingres’ Database project (which is how the project gets the name post-ingres or postgres ).
Postgres is one of the best open-source database alternative which is fully object oriented and transactions compliant. It has stored procedures, multiple views and a huge set of datatypes. Some of the other notable features are as follows.
Objects and Inheritance
Database consists of objects and the database administrators can design custom or user-defined objects for the tables. Inheritance is another feature. Tables can be set to inherit their characteristics from a “parent” table.
Functions
Functions can be used in Postgres. These can be written in the postgres’ own procedural language called ‘PL/pgSQL’ which resembles Oracle’s procedural language ‘PL/SQL’ or any other common scripting languages which support posgtres’ procedural language like PL/Perl, plPHP, PL/Python, PL/Ruby etc. Run the following in the psql client to determine if functions is enabled:
SELECT true FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'; 
To create user-defined functions we use the CREATE OR REPLACE FUNCTION command. Example:
CREATE OR REPLACE FUNCTION fib (

fib_for integer

) RETURNS integer AS $$

BEGIN

IF fib_for < 2 THEN

RETURN fib_for;

END IF;

RETURN fib(fib_for - 2) + fib(fib_for - 1);

END;

$$ LANGUAGE plpgsql;
Indexes
An index is like a summary of a certain portion of the table. It is an optimization technique which increases speed of accessing records from a database. PostgreSQL supports indexes like Btree, hash etc. User-defined index methods can also be created. Indexes are created on tables with respect to a particular field (based on which there are a number of queries). As an example for a table:
CREATE TABLE name (

id integer,

fname varchar

lname varchar

);
To create an index on table name with respective to the field id (as there are many queries on this table requesting for firstname or lastname from the id provided), we use the index:
CREATE INDEX name_id_index ON name (id);
Triggers
Triggers are events or functions run upon the action of certain SQL statements which modify data in some records. Depending on the kind of modification we can have multiple triggers in a database. Postgres supports multiple triggers written in PL/PgSQL or it’s scripting counterparts like PL/Python. The trigger function must be defined before the trigger can be created. The trigger function must be declared as a function taking no arguments and returning type trigger. CREATE TRIGGER command is used to declare triggers.
Concurrency
PostgreSQL ensures concurrency with the help of MVCC (Multi-Version Concurrency Control), which gives the database user a “snapshot” of the database, allowing changes to be made without being visible to other users until a transaction is committed.
PostgreSQL’s MVCC keeps all of the versions of the data together in the same partition in the same table. By identifying which rows were added by which transactions, which rows were deleted by which transactions, and which transactions have actually committed, it becomes a straightforward check to see which rows are visible for which transactions.
Inorder to accomplish this, Rows of a table are stored in PostgreSQL as a tuple. Two fields of each tuple are xmin and xmax. Xmin is the transaction ID of the transaction that created the tuple. Xmax is the transaction ID of the transaction that deleted it (if any).
Along with the tuples in each table, a record of each transaction and its current state (in progress, committed, aborted) is kept in a universal transaction log.
When data in a table is selected, only those rows that are created and not destroyed are seen. That is, each row’s xmin is observed. If the xmin is a transaction that is in progress or aborted, then the row is invisible. If the xmin is a transaction that has committed, then the xmax is observed. If the xmax is a transaction that is in progress or aborted and not the current transaction, or if there is no xmax at all, then the row is seen. Otherwise, the row is considered as already deleted.
Insertions are straightforward. The transaction that inserts the tuple simply creates it with the xmax blank and the xmin set to its transaction ID. Deletions are also straightforward. The tuple’s xmax is set to the current transaction. Updates are no more than a concurrent insert and delete.
Views
A view is a table which does not exist in the database. It is a virtual table created from fields in various tables and is joined together based on some criteria. Views can be used in place of tables and will accomplish the task same as that of a table. The CREATE VIEW statement is used to accomplish this eg:
CREATE VIEW best_sellers AS

SELECT * FROM publishers WHERE demand LIKE 'high';
Foreign Keys
The primary key used in one table which is used to refer to the records in a second table is called the foreign key of the second table.
CREATE TABLE products (
    product_no integer PRIMARY KEY,
    name text,
    price numeric
);
CREATE TABLE orders (
    order_id integer PRIMARY KEY,
    product_no integer REFERENCES products (product_no),
    quantity integer
);
Here product_no is the foreign key in the second table created. The foreign key field may have values which are repeated unlike primary keys.
Files Users and Configuration
The main configuration file of Postgres is postgresql.conf. This can be located in the ‘data’ directory. It may be present either in /var/lib (/var/lib/pgsql/data/postgresql.conf) or /usr/local (/usr/local/pgsql/data/postgresql.conf). Temporary changes to the configurations can be made using postmaster command.
The init script that starts the postgres service is /etc/init.d/postgresql . It runs a number of child processes concurrently. The postgres server process is postmaster. These processes and files associated with PosgreSQL are owned by the user/group postgres. The default port used for database connections is 5432
The user postgres is the PostgreSQL database superuser. We can create a number of super users for the database (this accomplished by the create role command ), however, the default super user is postgres. The postgres user has the privilege to access all the databases and files in the server (Unless the user root is created in postgres as a superuser).
Client Authentication is controlled by the file pg_hba.conf in the data directory, e.g., /var/lib/pgsql/data/pg_hba.conf. (HBA stands for host-based authentication.)
Each record specifies a connection type, a client IP address range (if relevant for the connection type), a database name or names, and the authentication method to be used for connections matching these parameters.A record is typically in one of two forms:
local database authentication-method [ authentication-option ]
host database IP-address IP-mask authentication-method [ authentication-option ]
local : This record pertains to connection attempts over Unix domain sockets.
host : This record pertains to connection attempts over TCP/IP networks.
database : Specifies the database that this record applies to. The value all specifies that it applies to all databases, while the value sameuser identifies the database with the same name as the connecting user.
authentication methods
trust: The connection is allowed unconditionally.
reject: The connection is rejected unconditionally.
password: The client is required to supply a password which is required to match the database password that was set up for the user.
md5: Like the password method, but the password is sent over the wire encrypted using a simple challenge-response protocol.
ident: This method uses the “Identification Protocol” as described in RFC 1413. It may be used to authenticate TCP/IP or Unix domain socket connections, but its reccomended use is for local connections only and not remote connections.
Front-ends
The minimalistic front-end for PostgreSQL is the psql command-line. It can be used to enter SQL queries directly, or execute them from a file. phpPgAdmin is a web-portal used for PostgreSQL administration written in PHP and based on the popular phpMyAdmin. Likewise pgAdmin is a graphical front-end administration tool for PostgreSQL, which has support on multiple platforms. The latest stable version of the same is pgAdmin III.
Some administration related commands
Command to login to psql database mydb as user myuser:
psql -d mydb -U myuser
Command to login to psql database mydb as user myuser on a different host myhost:
psql -h myhost -d mydb -U myuser
If the port the server runs is different we use -p [port number] . Upon entering the psql shell the prompt will show the database name currently being used. In the above example it will show
mydb=> (if logged in as an ordinary user )
mydb=# (if logged in as a super user like postgres)
Create a PostgreSQL user
There are two ways to create a postgres database user. The only user initially allowed to create users is postgres. So one has to switch to this user before creating other users with varying privileges.
1. Creating the user in the shell prompt, with createuser command.
switch to the postgres user with:
su - postgres

createuser tom

Shall the new role be a superuser? (y/n) n

Shall the new role be allowed to create databases? (y/n) y

Shall the new role be allowed to create more new roles? (y/n) n
2. Creating the user in the PSQL prompt, with CREATE USER command.
switch to the postgres user with:
su - postgres

create user mary with password 'marypass';
Creating and deleting a PostgreSQL Database
There are two way to create databases.
1. Creating database in the PSQL prompt, with createuser command.
CREATE DATABASE db1 WITH OWNER tom;
2. Creating database in the shell prompt, with createdb command.
createdb db2 -O mary
To delete an entire database from within the psql prompt do :
DROP DATABASE db1;
Determining execution time of a query
Turn on timing with
\timing
Now execute the qery:
SELECT * from db1.employees ;

Time: 0.065 ms
Calculate postgreSQL database size in disk
SELECT pg_database_size('db1');
to get the values in human readable format
SELECT pg_size_pretty(pg_database_size('db1'));
to calculate postgreSQL table size in disk
SELECT pg_size_pretty(pg_total_relation_size(‘big_table’));
Slash commands used in psql
To list all slash commands and thier purpose. Login to psql and issue to the command \? . Some of the most commonly used slash commands are the following:
List databases\l
System tables\dS
Types\dT
Functions\df
Operators\do
Aggregates\da
Users\du
Quit from psql\q
Connect to different database db2\c db2
Describe Table/index/view/sequence\d
The below can be used with a specific table/index/view name for description of the specific table/index/view
Tables\dt
Indexes\di
Sequences\ds
Views\dv
Useful Bash commands
Bash command to list all the postgresql databases:
psql -l #This can be run as a unix user who is also a super user in postgresql
Indirect bash command to list all the postgresl users:
psql -c '\du' #-c is used to run an internal or sql command in psql shell
Backing up and restoring databases
To dump the database to an sql file use the bash command:
pg_dump mydb > db.out
To restore a database from an sql backup file (via bash)
psql -d newdb -f backupdb.out

or

psql -f backupdb.out newdb
(here the database newdb must be already created and the file backupdb.out must be present in the current directory)
To take the backup of all the Postgres databases in the server:
pg_dumpall > /var/lib/pgsql/backups/dumpall.sql
(Only possible with the postgres or the database superuser )
Resetting database user’s password
To change the password for a database user (say ‘thomas’):
ALTER USER thomas WITH PASSWORD 'newpassword';
This same command can be used to reset the password for the postgresql super user postgres, but in this case, you will have to enable password less login for postgres user by adding the following line to the top of the file pg_hba.conf in the data directory of postgres. Once the password is reset this line can be removed:
local all postgres trust
Next we issue the same command but for the user postgres
ALTER USER postgres WITH PASSWORD 'newpassword';
To create a super user via bash with multiple roles
createuser -sPE mysuperuser
Instead of this we can also use the below psql shell command:
CREATE ROLE mysuperuser2 WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'mysuperpass2';
Physical database files in postgres
The files in data/base are named by the oid (Object Identifier) of the database record in
pg_database, like this:
cd /var/lib/pgsql/data/base

ls -l

total 33

drwx------ 22 postgres postgres 4096 Jul 23 20:06 ./

drwx------ 11 postgres postgres 4096 Aug  1 05:59 ../

drwx------  2 postgres postgres 4096 Jun 20 09:32 1/

drwx------  2 postgres postgres 4096 Mar  3 13:36 10792/

drwx------  2 postgres postgres 4096 Jun 20 15:09 10793/

drwx------  2 postgres postgres 4096 May 27 01:40 16497/

drwx------  2 postgres postgres 4096 May 27 01:40 16589/

drwx------  2 postgres postgres 4096 Jun 20 10:28 16702/

drwx------  2 postgres postgres 4096 May 27 01:40 16764/

drwx------  2 postgres postgres 4096 May 27 01:40 16785/

drwx------  2 postgres postgres 4096 Aug  1 04:37 16786/

drwx------  2 postgres postgres 4096 Aug  1 04:36 19992/

drwx------  2 postgres postgres 4096 May 27 01:40 19997/
To obtain the oid, execute the following command in psql prompt
postgres=# select oid,datname from pg_database order by oid;

   oid  |         datname

---------+--------------------------

1 | template1

10792 | template0

10793 | postgres

16497 | gadgetwi_Unable

16589 | vimusicc_filehost

16702 | personea_altissimo

16764 | shopping_businessfinance

16785 | ansonyi_wp2

16786 | ansonyi_wp

19992 | globook_PostgreSQL

Duplicity – secure incremental backup

Overview:

Duplicity is a tool to create GPG-encrypted (this way you can store your backups at remote servers without having to worry about who has access to your data) incremental backups to remote servers. Its a quite handy and secure method.
Installation
The steps to install duplicity is as follows
wget http://code.launchpad.net/duplicity/trunk/0.6.02/+download/duplicity-0.6.02.tar.gz
tar -xvf duplicity-0.6.02.tar.gz
cd duplicity-0.6.02.tar.gz
python setup.py install
If you come across any  librsync.so errors . You can resolve it by using the following steps
wget http://sourceforge.net/projects/librsync/files/librsync/0.9.7/librsync-0.9.7.tar.gz/download
tar -xzvf librsync-0.9.7.tar.gz
cd librsync-0.9.7
./configure
make
make install
Now we got duplicity installed :-)

Create a GPG key

In order to be able to encrypt your backups, you have to create a GPG key.  Open a second shell and run the following command (this generates some “randomness” on your system, which will be useful to create a secure key). Kill the command with CTRL+C when you are done with key generation.
while /bin/true; do cat /var/log/messages > ~/temp.txt; sleep 1; done;
On your other shell, create your GPG key. Be sure to use a secure passphrase and to copy/write down the key ID which is displayed at the end of the generation process (we’ll need it for ftplicity). Also, make sure to backup the key to a secure location outside your server. As all your backups will be encrypted, they will be worthless if your server crashes and you lose the key.
gpg –gen-key
Default options should be fine. This will create your key in ~/.gnupg/. Once its done you can verify the existence of your key using the command
gpg –list-keys
The next step is to prepare an off-site location to receive the backup files.
The software supports different protocols like FTP,RSYNC,SCpP.
I am restricting myself with SCP here

Simple unEncrypted Backup over SCP

Setup ssh keys on the backup server allowing root to seamlessly login to the backup server.
duplicity /home/me scp://uname@other.host/usr/backup

  • If the above command is run repeatedly, the first session will be a full backup, and subsequent ones will be incremental.
    The full option can be used to force a full backup. The next command also excludes the /tmp directory.
    duplicity full –exclude /tmp /home/me scp://uname@other.host/usr/backup
  • Basic restore command—restore the /home/me directory backed up with scp above to directory restored_dir:

  • duplicity scp://uid@other.host//usr/backup restored_dir

  • To enable verbose mode use the option -v
    Specify verbosity level (0 is total silent, 4 is the default, and 9 is noisiest)
    The command would look like
    duplicity  -v5 /home/me scp://uid@other.host/some_dir

    Encrypted Backup over SCP

    Here we use the GPG key generated earlier
    The format would be look like this
    duplicity
        --encrypt-key=${GPG_KEY} \
        --sign-key=${GPG_KEY} \
        --include=/boot \
        --include=/etc \
        --include=/home \
        --include=/root \
        --include=/var/lib/mysql \
        --exclude=/** \
        ${SOURCE} ${DEST}
    Needless to say the include and exclude options are for specifying the backup criteria.
    duplicity –encrypt-key=”FFF7730B” –sign-key=”FFF7730B” -v5 /home/me scp://uid@other.host/some_dir
    you will be asked for a GnuPG passphrase. You can type in any password you like; this has to be done everytime you run duplicity. The backup will be encrypted with the help of GnuPG. Permissions and ownerships will be preserved in the backup.
    To avoid this issue , you can simply set the passphrase as  environment variable using the command
    export PASSPHRASE=gpgpassphrase

    Backup Format & Explanation

    Once it is executed ,  you can see the backup in the server and it would look like the following way
    duplicity-full-signatures.2005-11-27T01:00:01-05:00.sigtar.gpg
    duplicity-full.2005-11-27T01:00:01-05:00.manifest.gpg
    duplicity-full.2005-11-27T01:00:01-05:00.vol1.difftar.gpg
    duplicity-full.2005-11-27T01:00:01-05:00.vol2.difftar.gpg
    The signatures file contains, signatures of each file that is backed up so that Duplicity can figure out which part of a file has changed. With that information it can upload only the missing part to complete a new backup set.
    The manifest file contains a listing of all the files in the backup set and a SHA1 hash of each file, probably so Duplicity can tell very quickly whether a file has been changed or not since the last backup.
    The volume files (vol1 and vol2) contain the actual file data. It appears that Duplicity volumes are at most 5MB. That’s helpful during restores so the entire backup set does’t not need to be downloaded to retrieve a single file. Duplicity will only download the volume containing that file.

    Common Options:

    Depending on the parameters and order of the parameters in the duplicity command, different functions can be performed. For example, an archive can be verified to see if a complete backup was made and what files, if any, have changed since the last backup.
    duplicity verify [options] source_url target_directory
    duplicity verify -v4 scp://user@bakuphost/etc /etc

    Listfiles

    It’s sometimes handy to check which files are in the latest backup set.
    duplicity list-current-files [options] target_url
    The command would look like
    duplicity list-current-files –archive-dir /root/test/ scp://user@backupserver/some_dir

    Restore

    The main purpose of backup is to restore data which has been lost.  The following is the common format for restoring the data from the latest backup
    duplicity scp://uid@other.host/some_dir  /home/me
    Duplicity enters restore mode because the URL comes before the local directory. If we wanted to restore just the file “Mail/article” in /home/me as it was three days ago into /home/me/restored_file:
    duplicity -t 3D –file-to-restore Mail/article scp://uid@other.host/some_dir /home/me/restored_file
    The following command compares the files we backed up, so see what has changed since then:
    duplicity verify scp://uid@other.host/some_dir /home/me
    The following command can be used to retrieve a  single file from backup
    duplicity –encrypt-key “” –sign-key “” –file-to-restore home/sburke/file.txt  scp://user@server.com/backup/  /var/tmp/file.txt
    1. The path to the file that is to be restored is relative to the directory on which the backup set is based. So in the command above,  home/sburke/file.txt plus the directory on which we based our backup (/backup) equals /backup/home/sburke/file.txt/. It would not work to put /backup/home/sburke/file.txt as the source path because the backup will not recognize /backup as a valid path. The last portion in the above command is the location where the file will be restored.
    To delete old backups, we can use the following  command
     duplicity --full --remove-older-than 1Y /media/data/backup scp://uid@server/personal
    To automate the tasks, you can write a shell script