logos

With Andrii Grytsenko


Technical Diary - With Andrii Grytsenko

Quickstart: backup on hard disk with AMANDA

In this post I will explain how to backup data to hard disk instead of tape with amanda backup tools over the network.

!!!CATION: Use this information on your own risk. Please remember that every step should be double checked unless you want to lose your data.

Preamble
I have two host and one of them will be used as backup server another as backup client:

  • node1 – uses as client it will be backuped side. It’s critical server and directory /etc should be backuped as well.
  • node2 – backup server which has good RAID equipment for backup mounted at /opt/backups.

Let’s start from server side:

SERVER SIDE

Go to the node2 and get all needed software

yum install amanda
yum install amanda-client
yum install amanda-server

After that we are ready to start server in over xinetd. Go to the /etc/xinetd.d directory and set directive

disable

to

no

in files : amanda, amandaidx and amidxtape.

service amanda
{
socket_type             = dgram
protocol                = udp
wait                    = yes
user                    = amanda
group                   = disk
server                  = /usr/lib/amanda/amandad
disable                 = no
}
service amandaidx
{
socket_type             = stream
protocol                = tcp
wait                    = no
user                    = amanda
group                   = disk
server                  = /usr/lib/amanda/amindexd
disable                 = no
}
service amidxtape
{
socket_type             = stream
protocol                = tcp
wait                    = no
user                    = amanda
group                   = disk
server                  = /usr/lib/amanda/amidxtaped
disable                 = no
}

to make new configuration works, restart xinted daemon:

/etc/init.d/xinetd restart

Check that everything is running:

netstat -a | grep amand

You should get something like that:

tcp        0      0 *:amandaidx                 *:*                         LISTEN
udp        0      0 *:amanda                    *:*

Make changes at .amandahosts allow users amanda and root from host localhost connect to server:

cat /var/lib/amanda/.amandahosts
localhost amanda  amindexd amidxtaped amdump
localhost.localdomain amanda  amindexd amidxtaped amdump
localhost root amindexd amidxtaped
localhost.localdomain root amindexd amidxtaped
node1 root  amindexd amidxtaped amdump

Set properly permissions to protect config from illegal access :

chmod 600 /var/lib/amanda/.amandahosts

I will store backups at local hard disk.Mount point is /opt/backups. First, make directory with read-write permissions for user amanda:

mkdir /opt/backups
chown amanda /opt/backups

Next step, check value in

tapecycle

at your amanda.conf. In my case it’s 25. That means that I should have 25 virtual tapes at my /opt/backups. Let’s create it and label, put in console next line:

i=1; while [ $i -lt 26 ]; do mkdir -v /opt/backups/slot$i; let i=i+1; done

also make symlink to first tape:

ln -s /opt/backups/slot1 /opt/backups/data

and set owner:

chown -R amanda.disk /opt/backups/

Now, login as amanda and label slots:

su - amanda
i=1; while [ $i -lt 26 ]; do /usr/sbin/amlabel DailySet1 DailySet1-$i slot $i; let i=i+1;  done

Check is everything labeled properly:

/usr/sbin/amtape DailySet1 show

Let’s take a look at amanda.conf. It’s located at /etc/amanda/DailySet1.

Below describe some change in configuration file which should be done.
Add new section into your amanda.conf :

define tapetype HARD-DISK {
comment "On Hard Disk"
length 3000 mbytes
}

Specify directory for backups:

tapedev "file:/opt/backups"

and change

tapetype

to

HARD-DISK
tapetype HARD-DISK

In section

define dumptype global

comment out and set to yes next:

index yes
record yes

Change

tpchanger

to this:

tpchanger "chg-disk"

If you have CentOS and Amanda Version 2.5.0p2 set chunksize to 0:

chunksize 0

to prevent errors concerning with recovery.

There is listing of main configuration file amanda.conf:

Next files and directories should be created set owner to user amanda:

touch /etc/amanda/DailySet1/tapelist
chown amanda /etc/amanda/DailySet1/tapelist
mkdir -p /dumps/amanda
chown amanda /dumps/amanda
mkdir /etc/amanda/DailySet1/curinfo
mkdir /etc/amanda/DailySet1/index
chown amanda /etc/amanda/DailySet1/index
chown amanda /etc/amanda/DailySet1/curinfo
mkdir  /etc/amanda/DailySet1/curinfo/localhost
chown amanda /etc/amanda/DailySet1/curinfo/localhost
mkdir  /etc/amanda/DailySet1/index/localhost
chown amanda /etc/amanda/DailySet1/index/localhost
mkdir /etc/amanda/DailySet1/curinfo/localhost/_etc
mkdir  /etc/amanda/DailySet1/index/localhost/_etc
chown amanda  /etc/amanda/DailySet1/index/localhost/_etc
chown amanda  /etc/amanda/DailySet1/curinfo/localhost/_etc
touch /etc/amanda/DailySet1/curinfo/localhost/_etc/info
chown amanda  /etc/amanda/DailySet1/curinfo/localhost/_etc/info

Also very important file disklist located at /etc/amanda/DailySet1. Its consist all targets which have to backuped.

cat disklist
node1 /etc comp-root-tar

CLIENT SIDE

First, you should install software:

yum install amanda-client

and edit access file:

cat /var/lib/amanda/.amandahosts
localhost amanda amindexd amidxtaped amdump
localhost  root amindexd amidxtaped
node2 amanda amindexd amidxtaped amdump
node2 root amindexd amidxtaped

Set properly permissions:

chmod 600 /var/lib/amanda/.amandahosts

And last step enable amanda in xinetd as was mentioned above. Set

disable = no

at /etc/xinetd.d/amanda and restart xinetd:

/etc/init.d/xinetd restart

LITTLE PRACTISE

Make test file at client side(node1) :

echo "test"  > /etc/testing

To make backup go to the node2 login as amanda and run

amdump
su - amanda
/usr/sbin/amdump  DailySet1 node1

Now you are ready to restore any file from backup. Go back to node1 and delete test file:

rm /etc/testing

Try to restart it over the amrecovery.

amrecovery -t node2 -s node2

if you get interactive mode type:

> sethost node1
> setdisk /etc
> add testing
> lcd /etc
> extract 

type “y” twice when you be prompted. Go to the /etc and check if was file restored:

cat /etc/testing
test

As you can see we successfully recover file which was mistaken delete.

!!!Keep in mind that in case of node1 will be failed date could be recovered from node2 as well.

1 Trackback to Quickstart: backup on hard disk with AMANDA

  1. By on May 4, 2010 at 05:29

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Categories

Translate