Linux - Tape Backup/Restore
SCSI tape drive
Rewind : /dev/st0
No-Rewind : /dev/nst0
BACKUP
======
Backup directory /www and /home with tar command (z - compressed):
# tar -czf /dev/st0 /www /home
To back up the entire file system using tar to a SCSI tape drive, excluding the /proc directory:
# tar -cpf /dev/st0 / --exclude=/proc
(-p switch indicates that we want to preserve the file permissions)
(-M switch, for multi-volume if the backup will not fit on a single tape)
The following line backs up all the files and directories listed in MyFiles, the /root directory, and all of the iso files in the /tmp directory:
# tar -cpf /dev/st0 -T MyFiles /root /tmp/*.iso
(-T switch, put the files and directories that you want to archive in a text file)
(note that the tar -T (or files-from) command cannot accept wildcards. Files must be listed explicitly.)
You could also execute a script to search the system and then build a list. Here is an example of such a script:
#!/bin/sh
cat MyFiles > TempList
find /usr/share -iname *.png >> TempList
find /tmp -iname *.iso >> TempList
tar -cpzMf /dev/st0 -T TempList
RESTORE
=======
Restore /www directory:
# cd /
# mt -f /dev/st0 rewind
# tar -xzf /dev/st0 www
To restore a file or files, the tar command is used with the extract switch (-x):
# tar -xpf /dev/st0 -C /
(-C / indicates that we want the restore to occur from /)
(-t switch lists the contents of an archive)
(-d switch compares the contents of the archive to current files on a system)
TAPE OPERATION
==============
Rewind tape drive:
# mt -f /dev/st0 rewind
Find out what block you are at with mt command:
# mt -f /dev/st0 tell
Display list of files on tape drive:
# tar -tzf /dev/st0
Unload the tape:
# mt -f /dev/st0 offline
Display status information about the tape unit:
# mt -f /dev/st0 status
Erase the tape:
# mt -f /dev/st0 erase
You can go BACKWARD or FORWARD on tape with mt command itself:
(a) Go to end of data:
# mt -f /dev/nst0 eod
(b) Goto previous record:
# mt -f /dev/nst0 bsfm 1
(c) Forward record:
# mt -f /dev/nst0 fsf 1
Rewind : /dev/st0
No-Rewind : /dev/nst0
BACKUP
======
Backup directory /www and /home with tar command (z - compressed):
# tar -czf /dev/st0 /www /home
To back up the entire file system using tar to a SCSI tape drive, excluding the /proc directory:
# tar -cpf /dev/st0 / --exclude=/proc
(-p switch indicates that we want to preserve the file permissions)
(-M switch, for multi-volume if the backup will not fit on a single tape)
The following line backs up all the files and directories listed in MyFiles, the /root directory, and all of the iso files in the /tmp directory:
# tar -cpf /dev/st0 -T MyFiles /root /tmp/*.iso
(-T switch, put the files and directories that you want to archive in a text file)
(note that the tar -T (or files-from) command cannot accept wildcards. Files must be listed explicitly.)
You could also execute a script to search the system and then build a list. Here is an example of such a script:
#!/bin/sh
cat MyFiles > TempList
find /usr/share -iname *.png >> TempList
find /tmp -iname *.iso >> TempList
tar -cpzMf /dev/st0 -T TempList
RESTORE
=======
Restore /www directory:
# cd /
# mt -f /dev/st0 rewind
# tar -xzf /dev/st0 www
To restore a file or files, the tar command is used with the extract switch (-x):
# tar -xpf /dev/st0 -C /
(-C / indicates that we want the restore to occur from /)
(-t switch lists the contents of an archive)
(-d switch compares the contents of the archive to current files on a system)
TAPE OPERATION
==============
Rewind tape drive:
# mt -f /dev/st0 rewind
Find out what block you are at with mt command:
# mt -f /dev/st0 tell
Display list of files on tape drive:
# tar -tzf /dev/st0
Unload the tape:
# mt -f /dev/st0 offline
Display status information about the tape unit:
# mt -f /dev/st0 status
Erase the tape:
# mt -f /dev/st0 erase
You can go BACKWARD or FORWARD on tape with mt command itself:
(a) Go to end of data:
# mt -f /dev/nst0 eod
(b) Goto previous record:
# mt -f /dev/nst0 bsfm 1
(c) Forward record:
# mt -f /dev/nst0 fsf 1
Comments
Post a Comment