1: Display status of the tape/drive
mt status #Use default
mt -f /dev/rmt/0 status #Unix
mt -f /dev/st0 status #Linux
mt -f /dev/nsa0 status #FreeBSD
mt -f /dev/rmt/1 status #Unix unity 1 i.e. tape device no. 1
|
You can use shell loop as follows to poll a system and locate all of its tape drives:
for d in 0 1 2 3 4 5
do
mt -f "/dev/rmt/${d}" status
done
|
2: Rewinds the tape
mt rew
mt rewind
mt -f /dev/mt/0 rewind
mt -f /dev/st0 rewind
|
3: Eject the tape
mt off
mt offline
mt eject
mt -f /dev/mt/0 off
mt -f /dev/st0 eject
|
4: Erase the tape (rewind the tape and, if applicable, unload the tape)
mt erase
mt -f /dev/st0 erase #Linux
mt -f /dev/rmt/0 erase #Unix
|
5: Retensioning a magnetic tape cartridge
If errors occur when a tape is being read, you can retension the tape, clean the tape drive, and then try again as follows:
mt retension
mt -f /dev/rmt/1 retension #Unix
mt -f /dev/st0 retension #Linux
|
6: Writes n EOF marks in the current position of tape
mt eof
mt weof
mt -f /dev/st0 eof
|
7: Forward space count files i.e. jumps n EOF marks
The tape is positioned on the first block of the next file i.e. tape will position on first block of the field
mt fsf
mt -f /dev/rmt/0 fsf
mt -f /dev/rmt/1 fsf 1 #go 1 forward file/tape
|
8: Backward space count files i.e. rewinds n EOF marks
The tape is positioned on the first block of the next file i.e. tape positions after EOF mark
mt bsf
mt -f /dev/rmt/1 bsf
mt -f /dev/rmt/1 bsf 1 #go 1 backward file/tape
|
Here is a list of the tape position commands:
fsf Forward space count files. The tape is positioned on the first block of the next file.
fsfm Forward space count files. The tape is positioned on the last block of the previous file.
bsf Backward space count files. The tape is positioned on the last block of the previous file.
bsfm Backward space count files. The tape is positioned on the first block of the next file.
asf The tape is positioned at the beginning of the count file. Positioning is done by first rewinding the tape and then spacing forward over count filemarks.
fsr Forward space count records.
bsr Backward space count records.
fss (SCSI tapes) Forward space count setmarks.
bss (SCSI tapes) Backward space count setmarks.
|
Basic backup commands
Let us see commands to backup and restore files
9: To backup directory (tar format)
tar cvf /dev/rmt/0n /etc
tar cvf /dev/st0 /etc
|
10: To restore directory (tar format)
tar xvf /dev/rmt/0n -C /path/to/restore
tar xvf /dev/st0 -C /tmp
|
11: List or check tape contents (tar format)
mt -f /dev/st0 rewind; dd if=/dev/st0 of=-
## tar format ##
tar tvf {DEVICE} {Directory-FileName}
tar tvf /dev/st0
tar tvf /dev/st0 desktop
tar tvf /dev/rmt/0 foo > list.txt
|
12: Backup partition with dump or ufsdump
## Unix backup c0t0d0s2 partition ##
ufsdump 0uf /dev/rmt/0 /dev/rdsk/c0t0d0s2
## Linux backup /home partition ##
dump 0uf /dev/nst0 /dev/sda5
dump 0uf /dev/nst0 /home
## FreeBSD backup /usr partition ##
dump -0aL -b64 -f /dev/nsa0 /usr
|
12: Restore partition with ufsrestore or restore
## Unix ##
ufsrestore xf /dev/rmt/0
## Unix interactive restore ##
ufsrestore if /dev/rmt/0
## Linux ##
restore rf /dev/nst0
## Restore interactive from the 6th backup on the tape media ##
restore isf 6 /dev/nst0
## FreeBSD restore ufsdump format ##
restore -i -f /dev/nsa0
|
13: Start writing at the beginning of the tape
## This will overwrite all data on tape ##
mt -f /dev/st1 rewind
### Backup home ##
tar cvf /dev/st1 /home
## Offline and unload tape ##
mt -f /dev/st0 offline
|
To restore from the beginning of the tape:
mt -f /dev/st0 rewind
tar xvf /dev/st0
mt -f /dev/st0 offline
|
14: Start writing after the last tar
## This will kee all data written so far ##
mt -f /dev/st1 eom
### Backup home ##
tar cvf /dev/st1 /home
## Unload ##
mt -f /dev/st0 offline
|
15: Start writing after tar number 2
## To wrtite after tar number 2 (should be 2+1)
mt -f /dev/st0 asf 3
tar cvf /dev/st0 /usr
## asf equivalent command done using fsf ##
mt -f /dev/sf0 rewind
mt -f /dev/st0 fsf 2
|
To restore tar from tar number 2:
mt -f /dev/st0 asf 3
tar xvf /dev/st0
mt -f /dev/st0 offline
|
Please do add if i have missed some commands.
No comments:
Post a Comment