This section presents common uses of the programs in the tape backup application. Complete information can be found in other sections of this manual.
In the examples that follow, the token "/dev/st0" is the value arbitrarily selected to represent the tape drive. The value you use may be different. The "$" sign indicates a non-superuser prompt. The "#" sign indicates a superuser prompt.
$ backup.s <Enter>
This command will perform a complete backup of this computer's hard disk. Backup.s is a shell script.
$ secondcopy /dev/st0 "compress no" "init Your_Volume_Name" <Enter>
The compress command enables and disables compression on those tape drives which offer the feature. The init command prepares a tape for saving files. An identifier is written to the first block on the tape. Any data on the tape is lost.
$ secondcopy /dev/st0 continue "errors /dev/par" save <list <Enter>
The continue command allows secondcopy to continue after recoverable errors. The errors command copies error messages to the named device or file. The save command copies files to tape. File names are read from stdin and can be typed from the keyboard, piped in, or redirected from a named file as shown here.
$ find / \( ! -type d ! -pname '/proc*' ! -pname '/tmp*' \) | secondcopy /dev/st0 verbose "e /tmp/slog" "continue yes" "links 400" compress save <Enter>
This command finds all files under the root directory except directories, and those in the /proc and /tmp directories. The find results are piped into secondcopy which operates verbosely, sends any errors to a file named /tmp/slog, does not stop when errors are detected, observes links and allows up to 400 unresolved links at any one time, and compresses the data on the way out to being saved on tape. Note that the "save" is placed at the very end of the options because of secondcopy's left to right processing of command line options.
$ echo "*" | secondcopy /dev/st0 "continue ask" verify <Enter>
This command will compare the files on tape with the files on disk. The "*" is interpreted as the pattern meaning all files on the tape. If the directory information and contents of the two are the same, secondcopy will print the filename and the word "verified". If the information does not match, secondcopy will print the filename and phrase "not verified". The reason for the mismatch will be printed on stderr.
Because the continue command was used with the ask option, secondcopy will stop and prompt the user when a mismatch occurs.
$ secondcopy /dev/st0 name <Enter>
This name command prints the volume name recorded on the tape. If there is no tape in the drive or if the tape has not been initialized, an error will be returned.
$ secondcopy /dev/st0 verbose list <Enter>
The verbose command, preceding the list command, changes the output of the list command. List will now print the group, member, size, date, and name of the files that have been saved on the tape. If the verbose command does not precede the list command, only the filenames will be displayed.
# secondcopy /dev/st0 restore <Enter>
junk*<Enter>
!junk[34]<Enter>
^d
This restore command copies files from the tape. SecondCopy interprets stdin as a list of filename patterns. In this example, the user will restore all of the files whose name begins with the "junk" except "junk3" and "junk4".
A pattern is a string of characters chosen from the set of legal filename characters and the special characters: '*', '?', '[', ']', '\', and '^'. An additional character, '!', is used to indicate the restore operation should be skipped for files which match the pattern.
# secondcopy /dev/st0 "restore -prefix" <Enter>
/boot/build/hard.1<Enter>
^d
The "-prefix" option of the restore command clips the the root designation from all filenames that have matched a pattern. This allows an entire directory branch to be rooted in a different node of the destination directory tree.
In this example SecondCopy will look for /boot/build/hard.1 on the tape and copy it to boot/build/hard.1. In this case, boot must a subdirectory of the current working directory. If hard.1 exists in the boot subdirectory, the user must have "w" permission for hard.1, or the restore operation will not proceed. If hard.1 does not exist in the subdirectory, the user must have "w" permission for the subdirectory or the restore operation will not proceed.
# cat /tmp/filelist | secondcopy /dev/st0 verbose "links"
"errors /tmp/rlog" "continue yes" restore <Enter>
The files listed in the file named /tmp/filelist are piped into secondcopy which then finds them on tape. In verbose mode, secondcopy will restore those files, continuing when it encounters errors, and writing error messages to a file named /tmp/rlog. The "links" entry here is really not necessary, because the setting of that option on the tape will override the command line setting during a restore.
$ secondcopy /dev/st0 "restore -prefix" <Enter>
/copyright.notice<Enter>
^d
This variation will look for /copyright.notice on the tape and restore it to copyright.notice, without using the '/' character, in the current directory.
# secondcopy /dev/st0 "restore /tmp" <Enter>
/boot/build/hard.1<Enter>
^d
The original path is completely overridden. SecondCopy will look for /boot/build/hard.1 on the tape and copy it to /tmp/hard.1. The directory tree of the old path is discarded and replaced with the new directory.
Don't use a '/' as the final character of the new_directory option: one will be added for you.
# scdir report <Enter>
directory1<Enter>
directory2<Enter>
^d
This command will print a report on each directory found in stdin, to stdout. This example shows the program being used on the console but stdin is intended to be the piped output of the find program and stdout is intended to be a file.
If you are familiar enough with the construction of directories, type in the following command, replacing persissions, links, and the other tokens with real values.
# scdir recreate <Enter>
permissions link count owner group size date name1 <Enter>
... name2 <Enter>
^d
This command will create each directory read from stdin. Stdin is intended to be a file of directory reports obtained from a previous use of scdir's report command.
If you are not that familiar with directories, try this.
# mkdir /tmp/xyz <Enter>
# echo "/tmp/xyz" | scdir report > /tmp/xyz.report <Enter>
# ls -D /tmp ; rmdir /tmp/xyz <Enter>
# scdir recreate </tmp/xyz.report <Enter>
# ls -D /tmp <Enter>
These commands will recreate a directory after it has been removed.
# scdir mkdir /tmp/a/b<Enter>
This command will create the directory named on the command line, including all missing directories in the path. If already /tmp/a exists as a file, and not as a directory, this command would fail.