1753332 Members
5430 Online
108792 Solutions
New Discussion юеВ

Re: Good old rm

 
SOLVED
Go to solution
P-Dicky
Frequent Advisor

Good old rm

Hello All

Here is a breif description of the point. I have a demo system that I restore production data to. I use data protector 5.5 and when restoring I alway select restore to a new location (this is a must). So on demo I restore prod data to say a mount point
/fpc/temp
When the data is restored it goes into /fpc/temp/fpc/temp I would like to move everything from /fpc/temp/fpc/temp to /fpc/temp and then rm the /fpc/temp/fpc folder. Is this the best and safest way?

cd /fpc/temp/fpc/temp
mv * /fpc/temp
cd /fpc/temp && rm -rf fpc

Thanks Everyone
10 REPLIES 10
Peter Godron
Honored Contributor

Re: Good old rm

Hi,
how about:
cd /fpc/temp/fpc/temp
# Create a tar of all the files with relative path
tar -cvf /fpc/tar.lis *
cd /fpc/temp
# Check the right was data backed up
tar -tvf /fpc/tar.lis
# Clear all the files
rm -r /fpc/temp/fpc
# Restore the files
tar -xvf /fpc/tar.lis

Benefit : You still have all the data if anything did go wrong
Hein van den Heuvel
Honored Contributor
Solution

Re: Good old rm

>> Is this the best and safest way?

Safest and using -f in the next sentence are mutaly exclusive.

>> cd /fpc/temp && rm -rf fpc

I would change that to tow commands:

rmdir /fpc/temp/fpc/temp
rmdir /fpc/temp/fpc

That would show you know what you are doing and give you a warning if there is a surprise.

Just my opinion.
Cheers,
Hein.
Christian Tremblay
Trusted Contributor

Re: Good old rm

to avoid these duplicates, check in DP, there is an restore option when you tell it where to restore.

There are 2 choices "restore into" or "restore as" I don't remember which is which but choose the other one that you are using now and you will avoid duplicating the directory tree and having to fix it afterwards like you are trying to do.
Hein van den Heuvel
Honored Contributor

Re: Good old rm

That mv is withing the same mountpoint no?
So you are not actually moving data, just directory entries. Pretty safe, and a tar seems a bit much, notably if the data could be re-restored if anything would go wrong.

Actually i would probably solve it with just:

ls /temp
mv /fpc/temp/fpc/temp /fpc/temp2
rmdir /fpc/temp/fpc
rmdir /fpc/temp
mv /fpc/temp2 /fpc/temp

no wildcard to make you go wildly wrong,
no force
minimimal system resources used.

Hein.
Yogeeraj_1
Honored Contributor

Re: Good old rm

hi,

It would better if you fix the restore problem instead! Restore the files to the right location and avoid the risks of making an error and extra tasks...


kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Christian Tremblay
Trusted Contributor

Re: Good old rm

Exactly my point....
P-Dicky
Frequent Advisor

Re: Good old rm


In the past someone used the over write and restored it to production instead of demo. Thus we are no longer allowed overwrite. You have to restore to an alternate location and move the data in. It is a demo system so if the script craps out it is no biggy

I know, not my rule.

Christian Tremblay
Trusted Contributor

Re: Good old rm

I am not talking about overwrite but choosing the right location for your restore
and the correct option to avoid duplicating the directory tree.

You can create a directory say /tmp/restore
(with enough space there to hold your restored data)Then in DP you chose that dir as your destination.

Let say you are restoring the file /home/joe/abc.txt, if you choose the "restore into" option in DP your file will be restored as /tmp/restore/home/joe/abc.txt

If you choose the "restore as" option you will end up with /tmp/restore/abc.txt and will not have to fix it afterwards.

Chris
P-Dicky
Frequent Advisor

Re: Good old rm

/fpc/temp is a mount point and Unix will not allow you to restore over it. So HP's fix is that I not check the mount point but all the dir's inside it. Some of them have 200 dir's that is alot of extra clicks.