Friday, August 21, 2009

Amanda Backup - Restore / Recover

Some Useful Commands

amrecover  To recover files & directory inside the dataset
amrestore  To restore the entire diskset



Status of the Tape Library,
#/usr/local/sbin/mtx -f /dev/changer status

To know the last taken backup details for the server bsma02 & the file system /opt,
# amadmin Full find bsma02 /opt/bmc/Datastore/oradata/.zfs/snapshot/today/

To know the status of most recent backup run,
#/opt/sfw/sbin/amstatus Full

Move a Tape from one slot [10] to another slot [65]
#/usr/local/sbin/mtx -f /dev/changer transfer 10 65

To label & enable the tape [ILO612L1] in Slot [10]
# /opt/sfw/sbin/amlabel Full ILO612L1 slot 10

Recover using amrecover utility

amrecover is the interactive utility in Amanda to recover the files and directories.

Valid amrecover utility sub commands are:

add path1 ... - add to extraction list (shell wildcards)
addx path1 ... - add to extraction list (regular expressions)
cd directory - change cwd on virtual file system (shell wildcards)
cdx directory - change cwd on virtual file system (regular expressions)
clear - clear extraction list
delete path1 ... - delete from extraction list (shell wildcards)
deletex path1 ... - delete from extraction list (regular expressions)
extract - extract selected files from tapes
exit
help
history - show dump history of disk
list [filename] - show extraction list, optionally writing to file
lcd directory - change cwd on local file system
ls - list directory on virtual file system
lpwd - show cwd on local file system
mode - show the method used to extract SMB shares
pwd - show cwd on virtual file system
quit
listdisk [diskdevice] - list disks
setdate {YYYY-MM-DD|--MM-DD|---DD} - set date of look
setdisk diskname [mountpoint] - select disk on dump host
sethost host - select dump host
settape [host:][device|default] - select tape server and/or device
setmode smb|tar - select the method used to extract SMB shares





Steps need to be followed:

Note: Compare the given steps with below given example which would help you to understand easily.

1. Initiate the amrecover command where the restore has to be performed.
Better create directory called ‘restore’ and from there try to recover which would help you not to overwrite files if any.
2. Even you can set this restore directory by command “lcd directory” at amrecover prompt & verify via “lpwd” command.
3. You can set the host where the recover is needed by, “sethost hostname” command.
4. List the disk sets configured on the hosts via “listdisk” command
5. Set the disk via “diskset dir” command
6. Using add & delete command add the files & directories which need to be recovered.
7. You can see the required Tape detail to restore by “list” command after adding the files & directories.
Note the Tape which should be required to recover the data. If required tape is not in tape library, bring it from offsite & load.
8. Extract the data by “extract” command and quit.

Example:

bash-2.05# /opt/sfw/sbin/amrecover Full
AMRECOVER Version 2.5.0p2. Contacting server on amanda ...
220 amanda AMANDA index server (2.5.0p2) ready.
200 Access OK
Setting restore date to today (2009-08-20)
200 Working date set to 2009-08-20.
Scanning /opt/amanda/Full...
Scanning /data0/amanda/Full...
Scanning /data1/amanda/Full...
Scanning /data2/amanda/Full...
200 Config set to Full.
200 Dump host set to amanda.
Trying disk / ...
$CWD '/' is on disk '/' mounted at '/'.
200 Disk set to /.
/
amrecover> sethost bsma02
200 Dump host set to bsma02.
amrecover> setdate ---05
200 Working date set to 2009-08-05.

amrecover> listdisk
200- List of disk for host bsma02
201- /
201- /usr
201- /var
201- /opt
201- /export/home
201- /opt/bmc/Datastore/oradata/.zfs/snapshot/today/
200 List of disk for host bsma02
amrecover> setdisk /opt/bmc/Datastore/oradata/.zfs/snapshot/today/
200 Disk set to /opt/bmc/Datastore/oradata/.zfs/snapshot/today/.
amrecover> ls
2009-08-04 rod/
2009-08-04 BMCPDS/
2009-08-04 .
amrecover> cd BMCPDS
/opt/bmc/Datastore/oradata/.zfs/snapshot/today//BMCPDS
amrecover> ls
2009-08-04 users01.dbf
2009-08-04 undotbs01.dbf
2009-08-04 tools01.dbf
2009-08-04 temp01.dbf
2009-08-04 system01.dbf
2009-08-04 sysaux01.dbf
2009-08-04 redo3b.log
2009-08-04 redo3a.log
2009-08-04 redo2b.log
2009-08-04 redo2a.log
2009-08-04 redo1b.log
2009-08-04 redo1a.log
2009-08-04 TESTSPACE01.dbf
2009-08-04 PV02_01.dbf
2009-08-04 PV01_01.dbf
2009-08-04 PSDP01_01.dbf
2009-08-04 PE01_02.dbf
2009-08-04 PE01_01.dbf
2009-08-04 NSDP01_01.dbf
2009-08-04 INDEX04_01.dbf
2009-08-04 INDEX03_01.dbf
2009-08-04 INDEX02_01.dbf
2009-08-04 INDEX01_01.dbf
2009-08-04 DATA04_01.dbf
2009-08-04 DATA03_01.dbf
2009-08-04 DATA02_01.dbf
2009-08-04 DATA01_01.dbf
2009-08-04 CONTROL2.CTL
2009-08-04 CONTROL1.CTL
2009-08-04 ARTMPF.dbf
2009-08-04 ARSYS.dbf
2009-08-04 .
amrecover> add users01.dbf
Added /BMCPDS/users01.dbf
amrecover> list
TAPE ILO617L1:65 LEVEL 0 DATE 2009-08-04
/BMCPDS/users01.dbf
amrecover> extract

Extracting files using tape drive chg-zd-mtx on host amanda.
The following tapes are needed: ILO623L1

Restoring files into directory /bsma02/opt/bmc/Datastore/oradata/restore
Continue [?/Y/n]? y

Extracting files using tape drive chg-zd-mtx on host amanda.
Load tape ILO617L1 now
Continue [?/Y/n/s/t]? y
. users01.dbf
amrecover>quit
200 Good bye.
bash-2.05#



Restore using amrestore command

You can not recover the whole disk set using amrecover utility. You can only recover directories & files inside the disk set.

But using amrestore you can restore the entire disk set.

Use the amadmin command åRun by Amanda user¨to find out the Tape, Backup Level & file information to restore as below.

$ /opt/sfw/sbin/amadmin Full find bsma02 /var
Warning: no log files found for tape ILO626L1 written 2009-08-21
Scanning /opt/amanda/Full...
20090821000900: found Amanda directory.
Scanning /data0/amanda/Full...
20090821000900: found Amanda directory.
Scanning /data1/amanda/Full...
20090821000900: found Amanda directory.
Scanning /data2/amanda/Full...
20090821000900: found Amanda directory.
Warning: no log files found for tape ILO626L1 written 2009-08-21
Scanning /opt/amanda/Full...
20090821000900: found Amanda directory.
Scanning /data0/amanda/Full...
20090821000900: found Amanda directory.
Scanning /data1/amanda/Full...
20090821000900: found Amanda directory.
Scanning /data2/amanda/Full...
20090821000900: found Amanda directory.

date host disk lv tape or file file part status
2009-01-02 bsma02 /var 0 ILO624L1 16 -- OK
2009-02-04 bsma02 /var 1 ILO606L1 18 -- OK
2009-07-25 bsma02 /var 1 ILO600L1 7 -- OK
2009-07-26 bsma02 /var 1 ILO600L1 31 -- OK
2009-07-27 bsma02 /var 0 ILO600L1 118 -- OK
2009-07-29 bsma02 /var 1 ILO622L1 2 -- OK
2009-07-31 bsma02 /var 1 ILO602L1 10 -- OK
2009-08-01 bsma02 /var 1 ILO602L1 123 -- OK
2009-08-02 bsma02 /var 0 ILO607L1 11 -- OK
2009-08-03 bsma02 /var 1 ILO603L1 57 -- OK
2009-08-04 bsma02 /var 1 ILO617L1 10 -- OK
2009-08-05 bsma02 /var 1 ILO615L1 4 -- OK
2009-08-07 bsma02 /var 1 ILO625L1 40 -- OK
2009-08-08 bsma02 /var 0 ILO620L1 16 -- OK
2009-08-09 bsma02 /var 1 ILO613L1 11 -- OK
2009-08-10 bsma02 /var 1 ILO612L1 11 -- OK
2009-08-11 bsma02 /var 1 ILO611L1 4 -- OK
2009-08-12 bsma02 /var 1 ILO616L1 4 -- OK
2009-08-13 bsma02 /var 1 ILO601L1 2 -- OK
2009-08-14 bsma02 /var 1 ILO619L1 59 -- OK
2009-08-15 bsma02 /var 0 ILO623L1 42 -- OK
2009-08-16 bsma02 /var 1 ILO621L1 10 -- OK
2009-08-17 bsma02 /var 1 ILO605L1 5 -- OK
2009-08-18 bsma02 /var 1 ILO618L1 5 -- OK
2009-08-19 bsma02 /var 1 ILO609L1 13 -- OK
2009-08-20 bsma02 /var 1 ILO608L1 4 -- OK
$

Restore the disk set using amrestore command.
You can mount the remote host if any using NFS and try restore.

# /opt/sfw/sbin/amrestore –f42 ILO623L1 bsma02 /var

The above command would create the file bsma02._var.20090815.0 in the current directory.

Using tar command, extract the data in the destination directory.

#tar xvBf –

Your data is restored now!!

No comments:

Post a Comment