When doing a Unix-to-Linux port, there are many steps involved in getting to the end-game. Some of the steps include the initial assessment, project planning, installing patches, and then building, configuring, tuning, testing, and ultimately deploying your new environment.
Suffice to say, some of the tasks are more exciting than others. Some tasks are just so mundane that they're usually considered no-brainers. The problem is, people tend to tune out when performing routine mundane tasks and this can lead to error. In this tip, we will focus on one of the less exciting tasks of systems administration: moving and copying files around, which is really no less critical than any other task, perhaps more-so, when you think of the importance of archiving your data properly.
In this addendum to the Unix to Linux Migration series, we'll examine this important, albeit mundane task.
As you should already know, while Unix and Linux may be similar, Linux is not Unix. In fact, there are many commands available in Unix which are just not available on Linux and vice-versa. Fortunately for you, many of the utilities used for file copying and compressing data files are similar. Let's use AIX, IBM's Unix, as an example. While AIX has utilities such as mksysb, backup and restorevg--Linux has none of these.
The bottom line is that you may need to forget all your neat proprietary Unix commands. Fortunately you can use older plain vanilla Unix standby types of tools and commands, such as tar, cpio, or dd, which are all available in some fashion on Linux and Unix.
CPIO
Let's start with cpio. I've always been a huge fan of cpio, partly because it can back up empty directories, while tar (its competition, if you will) does not. I can actually still recall one of the first commands I used in Unix, back in the good-old 1980's, on an old Compaq SystemPro (renamed by some as the SystemSlow, because of its poor performance, for those of you old enough to remember) running SCO Unix 3.2. The command was (and still is) cpio –ocvB >/dev/rmt0.
For example, if you wanted to back up all your files in a specific directory to tape, you would have used this syntax:
find ./ -depth -print | cpio –ocvB >/dev/rmt0
At this time, the –print is not necessary anymore, so you can just do this:
find ./ -depth | cpio –ocvB >/dev/rmt0
To restore the data, cd to the directory that you want to restore to, and than use this syntax:
cpio –icdumBv
For more options, or to drill down into greater detail about some of the flags used here, check the main pages for cpio. Another nice trick with cpio is packing multiple files to one file. You can even compress them on the fly. Here is how to do it.
Find ./ -depth | cpio –ocvB | gzip > yourfiles.cpio
Of course, this is assuming you have gunzip (gzip), which does not come installed in every Linux/Unix distribution. You can always download it from somewhere.
Tar
Tar is another utility you'll need to work with. To do a simple backup, do this:
tar cvf /dev/rmt/0
This will backup files in your current directory in tar format to your tape drive – assuming that rmt is your device. To restore the same files, you would use this syntax:
tar xvf /dev/rmt/0
This will restore those same files to your current directory, assuming that you backed up the tar files originally in relative and not absolute format. As a best practice, make certain that when backing up these files in tar or cpio, do not use an "absolute" path. If you do, you will not be able to choose where you can restore your files to and that can be critical when you must restore files to a different directory.
Whatever method you choose to backup and restore your data files, make sure you validate your backup strategy by running test backup restores. Be smart and always verify that your files are really on the tape or new disk area before you blow away your data. Do not ever assume anything!
Also, explore other ways, if possible, of moving over your data, rather than using tape drives. If you have a network in place with your Linux and Unix boxes and they have already been configured to communicate – you should be able to configure an NFS mount and just copy your files to another directory without using external tape-drives.
The bottom line is that because there are so many ways to skin a cat, make sure you spend the time in properly validating your strategy. The more time that you spend in planning your archiving strategy, the better off you will be long-term.

