Some tasks are so mundane that they're considered no-brainers. Trouble is, people often space out or turn off their brains when performing those tasks and make big mistakes. When doing a Unix-to-Linux port, there are many steps involved in getting to the final product. These include the initial assessment, installing patches, installing porting software, copying over and compressing files, configuring, tuning, testing and ultimately deploying that application. In this tip, we will focus on one of those tasks, perhaps not as sexy as some of the others, but no less critical. That would be moving your files. Before you yawn, let me tell you that I've seen some big goofs made by seasoned IT people who were blasÉ about moving files during a port.
As you know, while Unix and Linux may be similar, they are far from identical. There are many commands available in Unix which are just not available on Linux and vice-versa. Fortunately, many of the utilities used for file copying and compressing data files are similar. For example, let's take the IBM Unix flavor. AIX has things like mksysb, backup and restorevg. Forget all of them, please. You'll need to use plain old vanilla Unix standby types of utilities, such as tar, cpio, or dd, which are all available in some fashion on Linux and Unix.
I've always been a cpio fan because it can back up empty directories, and tar cannot. In fact, I can still recite one of the first commands I used in the 80's on an old Compaq SystemPro (renamed SystemSlow, because of its wonderful 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 I wanted to back up all my files in a specific directory to tape, I woud do this:
find ./ -depth -print | cpio –ocvB >/dev/rmt0
Fortunately, the –print is not necessary anymore, so you can just do this:
find ./ -depth | cpio –ocvB >/dev/rmt0
To restore the data, first cd to the directory that you want to restore to, and then try this:
For more options, or to understand further some of the flags used here, check the main pages for cpio.
Another nice trick with cpio is packing multiple files to one file, and even compressing them. You can do the same things with tar, also. Find
./ -depth | cpio –ocvB | gzip > myfiles.cpiowill dump your archive in cpio format and also compress it on the fly. Of course, this is assuming you have gzip, which does not come installed in every Linux/Unix distribution, but many of them.
Tar is another utility you'll need to work with. To do a simple backup, do
a : tar cvf /dev/rmt/0
This will backup files in your current directory in tar format to your tape drive (assuming again, rmt is your device).
To restore the same files, you would issue this command:
tar xvf /dev/rmt/0
This will restore those same files to your current directory, assuming again of course that you backed up the tar files originally in relative and not absolute format.
When backing up these files in tar or cpio, please do not use an "absolute" path, because 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, be smart and always verify that your files are really on the tape or new disk area before you blow away your data. Never assume anything. Also explore other ways, if possible, of moving over your data. If you have a network in place with your Linux and Unix machine, and they have been configured to already talk to one another, then you may not have to even move over the files this way. You would be able to set up an NFS mount and just copy your files to another directory.
There are many ways to skin a cat, so spend the proper time in planning, and you'll be the wiser for it down the road.