linux:amanda_backup
Amanda backup
This article describes how to setup backup routines on a a debian server using http://www.zmanda.com/. It does backup from multiple destinations including windows shares, a remote server and local folders. The backup is placed on a local USB mounted disk as virtual tapes. The following setup describes my private setup, and is thus shared here to document my settings and hopefully help others setting up their backup.
Systems I need backup for:
- Wolfram - Backup server
- Hydrogen.notfound.dk - remote server
- NAS box - remote samba share
Other ressources
Configuration files
First install amanda on the servers needed to be backed up. use eg. apt-get install amanda-server amanda-client on backup server and only amanda-client on clients.
Please note, that on Debian, the compiled user Amanda uses for backup is “backup”. This is important as amanda requires to be run as “backup” user. You can not change this unless amanda source is recompiled. This should however not give any problems but gave me som headache before I realized this. I guess it is configured this way for security reasons.
Create a file with the below content /etc/amanda/DailySet1/amanda.conf
- amanda.conf
#indexdir "/mnt/usbhd1/backup/state/index" org "DailySet1" # your organization name for reports mailto "root@localhost" # space separated list of operators at your site dumpuser "backup" # the user to run dumps under logdir "/etc/amanda/DailySet1/logs" # log directory infofile "/etc/amanda/DailySet1/curinfo" # database filename indexdir "/etc/amanda/DailySet1/index" # index directory tapelist "/etc/amanda/DailySet1/tapelist" # list of used tapes tapecycle 9 tapes tapetype DISK tpchanger "chg-disk" changerfile "/etc/amanda/DailySet1/changer" # needed by amlabel tapedev "file:/mnt/usbhd1/backup/vtapes/DailySet1/slots" define tapetype DISK { comment "Backup to HD" length 50 gbytes } # comment holding disk section if needed holdingdisk hd1 { directory "/mnt/usbhd1/backup/holding" use 50 Gb } define dumptype daily { global comment "daily dumptype" compress server best program "GNUTAR" strategy standard priority high exclude list "/etc/amanda/DailySet1/global-debian-exclude.list" } define dumptype simple-gnutar-local { auth "local" compress server best program "GNUTAR" exclude list "/etc/amanda/DailySet1/global-debian-exclude.list" } define dumptype comp-user-tar { auth "local" compress server best program "GNUTAR" # exclude list "/etc/amanda/DailySet1/global-debian-exclude.list" } define dumptype comp-tar-ssh { auth "ssh" compress client best program "GNUTAR" client_username "backup" ssh_keys "/var/backups/.ssh/id_rsa" # exclude list "/etc/amanda/DailySet1/global-debian-exclude.list" }
backup through SSH
First lets create the ssh key files.
mkdir -p /var/backups/.ssh ssh-keygen -t rsa -C "Amanda backup key"
backup remote samba shares
backup local shares on backup server
Restore files
This section describes howto restore files on with amanda backup. Also note this section only handles howto restore on the backup server, not on the clients.
First log in as root, and make sure you place your self in the directory where you want to restore the files. Suggestion, use /tmp and create a directory here for testing purpose. Next run amrecover
$ mkdir /tmp/recover $ amrecover
Lets for instance say we want to restore a file on hydrogen in /home/joe, file myfile from 2011-03-01.
In amrecover please note you can use ? to get more help. We need to set the date we want to restore to. Use setdate.
amrecover> setdate 2011-03-01
Next get a list of hosts.
amrecover> listhost amrecover> sethost hydrogen
Next select the disk to backup from.
amrecover> listdisk amrecover> setdisk /home
use the command cd to change directory as on normal filesystem, ls to list files and add to mark the files for extraction.
amrecove> cd joe amrecover> add myfile.txt amrecover> extract amrecover> quit
And your done.
Usefull commands
How to kill a running backup. As backup user run
$ amcleanup -k <backup set name>