Sunday, April 4, 2010

Amanda Backup Solution

SkyHi @ Sunday, April 04, 2010

Introduction



Amanda is the world's most popular Open Source Backup and Archiving software. Amanda allows System Administrators to set up a single
backup server to back up multiple hosts to a tape- or disk- or cloud-based storage system. Amanda uses native archival tools and can back
up a large number of workstations and servers running various versions of Linux, Unix (including OpenSolaris), Mac OS X or Microsoft
Windows operating systems (Native Win32 Client and Samba).



This documentation will cover a backup setup of Amanda on a Linux Server, Linux Client, and Windows Client. I am using the following
Virtual Machines:



  • amserver.jgaetz.ca - 142.25.97.110 - the Linux Server
  • amlinuxclient.jgaetz.ca - 142.25.97.181 - the Linux Client
  • amwinclient.jgaetz.ca - 142.25.97.115 - the Windows Client


Preparing the machines



For this guide, I'll be using CentOS 5.4 as the Linux Client and server and Windows Vista for the Windows Client. Each of the
Clients, and the server, are running on a 32-Bit architecture.


Linux Server



  1. Install CentOS 5
  2. Apply all available updates
  3. Set a static IP for the machine

    • Type setup in a terminal (while logged in as root) and hit ENTER.
    • Choose Network Configuration
    • Select the eth0 interface
    • Configure your IP settings

      • Static IP: 142.25.97.110
      • Netmask: 255.255.255.0
      • Default Gateway IP: 142.25.97.254


  4. Run: service network restart to apply the changes



Linux Client



  1. Install CentOS 5
  2. Apply all available updates
  3. Set a static IP for the machine

    • Type setup in a terminal (while logged in as root) and hit ENTER.
    • Choose Network Configuration
    • Select the eth0 interface
    • Configure your IP settings

      • Static IP: 142.25.97.181
      • Netmask: 255.255.255.0
      • Default Gateway IP: 142.25.97.254


  4. Run: service network restart to apply the changes


Windows Vista Client



  1. Install Windows Vista which service pack does not matter
  2. Apply all available updates
  3. Set a static IP for the machine


    • Navigate to your Network Connections (Control Panel -> Network and Internet -> Network Connections)
    • Right Click on the "Local Area Connection" Icon and Click Properties
    • If the UAC (User Account Control) promps you click Continue
    • Once the Local Area Properties Window Opens, Click on Internet Protocol Version 4 (TCP/IPv4) and Click Properties
    • Configure your IP settings


      • Static IP: 142.25.97.115
      • Netmask: 255.255.255.0
      • Default Gateway IP: 142.25.97.254
      • Preferred DNS server: 142.25.97.254
      • Alternate DNS server: 142.25.115.12




  4. Your IP settings should have automaticaly changed, but to be safe open up your Command Promp Under Administrater and run ipconfig
    /release and once thats done run ipconfig /renew and to check if your IP Settings have been change run ipconfig /all and look
    under Ethernet adapter Local Area Connection:


Installing and Configuring Amanda



Linux Server



  1. Login is as root.
  2. Make a directory to store the Amanda_RPM Run: mkdir /root/amanda_rpm
  3. Navigate to the directory you just created Run: cd /root/amanda_rpm
  4. Download the Amanda Server Run: wget http://www.zmanda.com/downloads/community/Amanda/2.6.0p2/Redhat_Enterprise_5.0/amanda-backup_server-2.6.0p2-1.rhel5.i386.rpm
  5. Install the Amanda Server Run: rpm -ivh amanda-backup_server-2.6.0p2-1.rhel5.i386.rpm
  6. Now we'll need to unlock the amandabackup user the RPM creates for us Run: passwd -u -f amandabackup
  7. Now to Create a configuration folder for Amanda, the most common name used is DailySet1 Run: mkdir /etc/amanda/DailySet1
  8. Navigate to the directory you just created Run: cd /etc/amanda/DailySet1
  9. Download the amanda.conf file Run: wget http://portfolio.itas.ca/~leeb/amanda/files/amanda.conf
  10. Open the file using vi Run: vi amanda.conf
  11. Once in amanda.conf, Make the following changes:


    • org "John's Backup"
    • mailto "john.gaetz@itas.ca
    • dumpuser "amandabackup"
    • dumpcycle 14 days
    • tapecycle 4 tapes
    • runtapes 1
    • tpchanger "chg-multi"
    • tapedev "file:/var2/amandadumps"
    • labelstr "^DailySet1[0-9][0-9]*$" (I got an error with this line so I change it to "DailySet1")

    • define tapetype HARD-DISK {

           comment "Save to disk"

           length 4000 mbytes

      }

    • holdingdisk hd1 {

           comment "main holding disk"

           directory "/dumps/amanda" # where the holding disk is

           use -700 Mb # how much space can we use on it

           # a non-positive value means:

           # use all space but that value

      }
    • In the dumptype global block, add: auth "bsdtcp"



    • Save the file and exit out of vi




    • We've set the mail address where we'll receive e-mails from Amanda, the user Amanda will run as, specified that
      we'll be using 4 tapes, and specified a path where the tapes will reside. In addition, a new HARD-DISK tapetype has been added with
      a size of about 4GB.




  12. Once Amanda.conf is configured, We'll need to setup the tapes. Create the tapelist file Run: touch /etc/amanda/DailySet1/tapelist
  13. Setup the changer.conf file Run: vi /etc/amada/DailySet1/changer.conf
  14. Once in the changer.conf file make the following changes:




    • multieject 0
    • gravity 0
    • needeject 0
    • ejectdelay 0
    • statefile /var/lib/amanda/DailySet1/changer-status
    • firstslot 1
    • lastslot 4
    • slot 1 file:/var2/amandadumps/tape01
    • slot 2 file:/var2/amandadumps/tape02
    • slot 3 file:/var2/amandadumps/tape03
    • slot 4 file:/var2/amandadumps/tape04
    • Save the file and exit out of vi


  15. Now we need to create those slot folders on the server machine
  16. Run the Following commands:



    • mkdir -p /var2/amandadumps/tape01/data
    • mkdir -p /var2/amandadumps/tape02/data
    • mkdir -p /var2/amandadumps/tape03/data
    • mkdir -p /var2/amandadumps/tape05/data



  17. Make sure the amandabackup user can actually read and write to the tapes
  18. Run the Follow commands:


    • chown -R amandabackup:disk /var2/amandadumps/
    • chmod -R 770 /var2/amandadumps/
    • chown -R amandabackup:disk /etc/amanda/DailySet1/




  19. Now we need to label the tapes (in the manner specified in the labelstr line in Amanda.conf). Labeling needs to be done as the
    amandabackup user.
  20. Switch over to the amandabackup user Run: su - amandabackup
  21. Run The following Commands:


    • amlabel DailySet1 DailySet101 slot 1
    • amlabel DailySet1 DailySet102 slot 2
    • amlabel DailySet1 DailySet103 slot 3
    • amlabel DailySet1 DailySet104 slot 4



  22. Create a disklist file to specify which hosts will be backed up, and which folders to backup on those hosts
    Run: vi /etc/amanda/DailySet1/disklist
  23. Once in the disklist, Make the Following Changes:


    • amserver.jgaetz.ca /myfiles comp-root-tar
    • amlinuxclient.jgaetz.ca /myfiles comp-root-tar
    • Save and exit out of vi


  24. Return to the root user Run: exit
  25. Now edit the .amandahosts file to make sure all of the hosts can communicate with each other Run: vi /var/lib/amanda/.amandahosts
  26. Once in the .amandahosts file, Make the following Changes:


    • localhost root amindexd amidxtaped
    • localhost amandabackup amdump
    • localhost.localdomain root amindexd amidxtaped
    • localhost.localdomain amandabackup amdump
    • amserver.jgaetz.ca amandabackup
    • amserver.jgaetz.ca root amindexd amidxtaped
    • amserver amandabackup
    • amserver root amindexd amidxtaped
    • amlinuxclient amandabackup
    • amlinuxclient root amindexd amidxtaped
    • amlinuxclient.jgaetz.ca amandabackup
    • amlinuxclient.jgaetz.ca root amindexd amidxtaped
    • Save and exit out of vi


  27. Now to edit the host file to make sure the hosts or communicating properly Run: vi /etc/hosts
  28. Once in the hosts file, Make the following Changes:


    • # Do not remove the following line, or various programs
    • # that require network functionality will fail.
    • 127.0.0.1 localhost.localdomain localhost amserver
    • ::1 localhost6.localdomain6 localhost6
    • 142.25.97.110 amserver.jgaetz.ca amserver amserver
    • 142.25.97.181 amlinuxclient.jgaetz.ca amlinuxclient amlinuxclient
    • Save and exit out of vi


  29. Now to make sure that Amanda can sendmail, start the sendmail service Run: service sendmail start
  30. The directory where the holding disk will reside will also need to be created and given proper ownership
  31. Run the following Commands:


    • mkdir -p /dumps/amanda
    • chown -R amandabackup:disk /dumps


  32. The following files and pathes will need to exist in order to stop amcheck from spitting out errors about them.
  33. Run the following Commands:


    • mkdir -p /etc/amanda/DailySet1/curinfo/amserver.jgaetz.ca/_myfiles
    • touch /etc/amanda/DailySet1/curinfo/amserver.jgaetz.ca/_myfiles/info
    • mkdir -p /etc/amanda/DailySet1/curinfo/amlinuxclient.jgaetz.ca/_myfiles
    • touch /etc/amanda/DailySet1/curinfo/amlinuxclient.jgaetz.ca/_myfiles/info
    • mkdir -p /etc/amanda/DailySet1/index/amserver.jgaetz.ca/_myfiles
    • touch /etc/amanda/DailySet1/index/amserver.jgaetz.ca/_myfiles/info
    • mkdir -p /etc/amanda/DailySet1/index/amlinuxclient.jgaetz.ca/_myfiles
    • touch /etc/amanda/DailySet1/index/amlinuxclient.jgaetz.ca/_myfiles/info


  34. Create the myfiles directory that will be backed up on the server Run: mkdir /myfiles
  35. Make the amandabackup user the owner of the /myfiles directory Run: chown -R amandabackup:disk /myfiles
  36. Make sure everything in the DailySet1 configuration is owned by amandabackup Run: chown -R amandabackup:disk /etc/amanda/DailySet1


Linux Client



  1. Login is as root.
  2. Make a directory to store the Amanda_RPM Run: mkdir /root/amanda_rpm
  3. Navigate to the directory you just created Run: cd /root/amanda_rpm
  4. Download the Amanda Client Run: wget http://www.zmanda.com/downloads/community/Amanda/2.6.0p2/Redhat_Enterprise_5.0/amanda-backup_client-2.6.0p2-1.rhel5.i386.rpm
  5. Install the Amanda Client Run: rpm -ivh amanda-backup_client-2.6.0p2-1.rhel5.i386.rpm
  6. Now we'll need to unlock the amandabackup user the RPM creates for us Run: passwd -u -f amandabackup
  7. Now we need to edit the .amandahosts file to make sure all hosts can communicate with each other Run: vi /var/lib/amanda/.amandahosts
  8. Once in the .amandahosts file, Make the following changes


    • localhost amandabackup amdump
    • localhost.localdomain amandabackup amdump
    • amlinuxclient.jgaetz.ca amandabackup
    • amlinuxclient.jgaetz.ca root amindexd amidxtaped
    • amlinuxclient amandabackup
    • amlinuxclient root amindexd amidxtaped
    • localhost amandabackup
    • localhost root amindexd amidxtaped
    • localhost.localdomain amandabackup
    • localhost.localdomain root amindexd amidxtaped
    • amserver.jgaetz.ca amandabackup amdump
    • Now Save and Exit Vi


  9. Now edit the amanda-client file Run: vi /etc/amanda/amanda-client
  10. Once in the amanda-client file Make the following changes


    • index_server "142.25.97.110"
    • tape_server "142.25.97.110"


  11. Now edit the hosts file Run: vi /etc/hosts
  12. Once in the hosts file, Make the following changes


    • # Do not remove the following line, or various programs
    • # that require network functionality will fail.
    • 127.0.0.1 localhost.localdomain localhost amlinuxclient
    • ::1 localhost6.localdomain6 localhost6
    • 142.25.97.110 amserver.jgaetz.ca amserver amserver
    • 142.25.97.181 amlinuxclient.jgaetz.ca amlinuxclient amlinuxclient
    • Now Save and Exit vi


  13. NowCreate the myfiles directory that will be backed up on the client Run: mkdir /myfiles
  14. Now give ownership of the myfiles directory to amandabackup Run: chown -R amandabackup:disk /myfiles


Windows Client


  1. Lets start by creating a myfiles directory in your c:\ directory
  2. Create an amandabackup user the machine and put the password as amanda
  3. Go to the c:\myfiles Properties
  4. Go to the Sharing tab
  5. Click Advanced Sharing
  6. Check the "Share this folder checkbox"
  7. Click the Permissions button
  8. Remove the Everyone user
  9. Add the amandabackup user and give it full permissions


  10. We just made a windows share that will mount to a win_share folder in the myfiles directory on the Linux Client.


  11. Go back on your Linux Client and login as root.
  12. Make a folder for your Windows Share Run: mkdir /myfiles/win_share
  13. If you don't have samba install Run: yum install samba
  14. Now start samba Run: service smb start
  15. Now mount the share to the win_share folder Run: mount -t cifs -o username=amandabackup,password=amanda //amwinclient.jgaetz.ca/myfiles /myfiles/win_share
  16. Now anything in the myfiles folder on the Windows Client will show up in the win_share folder on the Linux Client


Backing up


  1. Log into your Linux server as the amandabackup Run: su - amandabackup
  2. Check to see if your Amanda Server is configured properly Run: amcheck DailySet1
  3. If everything was done right you should not get any errors
  4. Now it's time to run the backup Run: amdump DailySet1


Recovering Files



  1. Login to your Linux client as root
  2. Navigate to the directory you want the files backed up to in this case its /myfiles Run: cd /myfiles
  3. Run amrecover
  4. List the available hosts Run: listhost
  5. Set your host Run: sethost amlinuxserver.jgaetz.ca
  6. List the available Disks Run: listdisk
  7. Set the Disk Run: setdisk /myfiles
  8. Check what files are available to recover Run: ls
  9. Add the files you want to recover to the extraction list Run: Add File_Name_goes_here
  10. Extract the files Run: extract


  11. All of the files you wanted to recover from your server should now be the /myfiles directory on the Linux Client.




Valid HTML 4.01 Transitional


REFERENCE

http://portfolio.itas.ca/~john.gaetz/itas257/amandadoc.html