Operating System - HP-UX
1748234 Members
3380 Online
108759 Solutions
New Discussion юеВ

How to rename the restored file?

 
SOLVED
Go to solution
Ngoh Chean Siung
Super Advisor

How to rename the restored file?

Hi,

Let say I want to restore a file from tape and the path name is /tmp/test/123.txt

So, I go to the /u directory first and issue this command tar xvf /dev/rmt/0m /tmp/test/123.txt

Question:
1) Is there command to rename the file name during the restoration? How about others method like fbackup, cpio and ...?

regard
8 REPLIES 8
Michael Tully
Honored Contributor

Re: How to rename the restored file?

If a file is on a tape in a certain format, in your case tar, you can't use another backup tool to restore it. You could try to use a pipe, but I'm not sure that will work either. You basic problem is that the file was backed up using an absolute path name.
Anyone for a Mutiny ?
Ngoh Chean Siung
Super Advisor

Re: How to rename the restored file?

Hi,

For my case, the restored file will be located at /u/tmp/test/123.txt

I want to rename it to 456.txt instead of 123.txt during issue the tar command to restore. Is it able to do it?

regards
Michael Tully
Honored Contributor
Solution

Re: How to rename the restored file?

As a test I tried this with a relatively small file and it worked. You could encounter a problem if the file is quite large.

# tar xvf /dev/rmt/0m /tmp/test/123.txt | xargs mv /tmp/test/123.txt /u/456.txt

As a test I had a file of the same name and it did not get removed. It would be quite easy to test it yourself anyway. Just use a tarball archive file instead of a tape.

# tar cvf /tmp/crud /tmp/typescript

# tar xvf /tmp/crud | xargs mv /tmp/typescript /home/myfile
Anyone for a Mutiny ?
Sanjay Kumar Suri
Honored Contributor

Re: How to rename the restored file?

I don't think restore and rename can happen together in tar (or for that matter other tools such as fbackup, cpio etc.)

It has to be two stage process. For example:

tar xvf /dev/rmt/0m 123.txt;mv 123.txt 456.txt

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Mike Stroyan
Honored Contributor

Re: How to rename the restored file?

The pax command will read tar format.
It has the -s option to replace patterns in file names.
It has the -i option to prompt for new file names.
Bill Hassell
Honored Contributor

Re: How to rename the restored file?

tar is a very poor tool to use for backups. If your backup specification starts with /, then tar has no choice but to restore the file to exactly where it was saved. Any path that starts with / (as in /tmp/test/123.txt) means that you cannot restore the file with tar to anywhere else. And there is no name change possible.

Instead, change your command to:

cd /tmp
tar cvf /dev/rmt/0m test/123.txt

Now list the contents and you'll see:

test/123.txt

Now you can restore this directory and file in any directory. Just cd to the directory and restore the file. pax is much smarter than tar, and fbackup is much better than any of the classic Unix utilities, especially for this task.


Bill Hassell, sysadmin
Ngoh Chean Siung
Super Advisor

Re: How to rename the restored file?

Hi all,

Currently the backup methods that I know is fbackup, tar, cpio and pax. May I know any difference between these methods? Just want to get all of your option whether which is the best method to backup? In term of user friendy, backup & restore efficiency & time and etc.

regards
Bill Hassell
Honored Contributor

Re: How to rename the restored file?

A backup strategy requires a lot of thought. For *ALL* HP 9000 computers running HP-UX, you must download the latest version of Ignite/UX from http://www.software.hp.com/products/IUX/

I say: "must" because this is the only sane way to restore your system should the root disk go bad or be accidently erased. You will need a tape drive on your system, or you can use another HP-UX computer to act as a network respository for your backups. In either case, you'll need to spend some time reading the Ignite/UX docs for make_tape_recovery, and search the ITRC forums for suggested command line values to backup your VG00 disk(s).

While Ignite/UX will backup your files and create a bootable restore tape, recovering a few files from that tape is very convoluted. That's where a file backup tool such as tar, cpio and fbackup come in. Classic Unix tools cannot backup large files (such as a 15Gb file) so they are no longer as useful as they were several years ago. Also, these tools are very primitive. There is no table of contents, no error recovery and no formal method to handle multiple tapes.

fbackup is the best (free) backup tool in that it has many of the features found in commercial (not free) backup tools. It has a complete directory at the beginning of each tape, has an interface to handle multiple tapes and auto-changers, reads data from as many as 6 files simulataneously to keep the backup running full speed, and adds high speed search marks to the tape for very fast restores of a few files. Additionally, it has error recovery in case the tape has a bad spot.

If you are aware of the limitations and also aware of how your current system(s) will fare using tar, cpio, pax, etc, then these tools do work. However, for speed and reliability, fbackup/frecover are the tools of choice. Note that fbackup is HP-UX proprietary. Like most commercial backup programs, the format is not interchangeable with any other backup tool (especially on other non-HP-UX platforms).


Bill Hassell, sysadmin