# How to automate answering questions on FreeBSD restore?



## hockey97 (Feb 14, 2014)

Hi, I  am running restore. I am restoring my system from a dump I took. The problem is that when I run the restore. after the first 20 min_ute_s of running the restore, I get about 20 lines of hard link errors  printed to the screen. Then after that maybe 30 minutes after that. I get a series of  abort questions  asking  `[y/n]?`. Before this question it shows two directories showing a restoring of the freebsd FreeBSD handbook on my system. It gives this error for each file or documentation inside the freebsd FreeBSD handbook. These questions are never ending. I assume there's more then 20,000 of them. I would like to know the command used to automate the same question that's repeated to be answered with the N  or n   for no. Since the question requires only a  y or n as a response. 

 I don't know if this is normal or this is a hint that the dump is corrupted. Does anyone have any advice for me? Does anyone know the command to respond to each abort question with a n  response?


----------



## wblock@ (Feb 15, 2014)

What options are you using with restore(8)?


----------



## hockey97 (Feb 15, 2014)

wblock@ said:
			
		

> What options are you using with restore(8)?


This is what I type for the restore command: `restore -rf /mnt/da0s1d.dump`.


----------



## wblock@ (Feb 15, 2014)

If the filesystem is not empty, add -u to unlink (remove) files before writing new ones from the restore.


----------



## hockey97 (Feb 15, 2014)

wblock@ said:
			
		

> If the filesystem is not empty, add -u to unlink (remove) files before writing new ones from the restore.


I tried it just now and I still get the same errors. *H*ere is that error line that is repeated 20 times: 

```
warning cannot create hard link ./sbin/...
```

It looks like everything inside the sbin folder is generating warnings that it fails to create a hard link. *N*ow the abort questions are showing up. Here's the exact message:

```
parent name ./usr/local/share/doc/freebsd/en_US.ISO8859-1/articles/checkpoint
sibling name ./usr/local/share/doc/freebsd/en_US.ISO08859-1/articles/checkpoint/articles.ps
entry type: LEAF
inode number: 96847279
flags: NEW
abort? [yn]
```

*T*hat is what most of them look like. I still have to manually keep typing `n`  to respond to the question to not abort.  Any ideas?

This looks like a similar problem that another member had: https://forums.freebsd.org/viewtopic.php?t=1847


----------



## wblock@ (Feb 15, 2014)

You still have not shown a complete form of that hard link error.  There are commands in /sbin that have the schg file flag set and can't be overwritten.  If that is the problem, clearing those flags with `chflags noschg /sbin/...` before the restore would fix that problem.


----------



## hockey97 (Feb 15, 2014)

wblock@ said:
			
		

> You still have not shown a complete form of that hard link error.  There are commands in /sbin that have the schg file flag set and can't be overwritten.  If that is the problem, clearing those flags with `chflags noschg /sbin/...` before the restore would fix that problem.



Ok, I will give that command a try. If it doesn't work then I will come back here posting the full message that is given to the screen. However, what about the part where it starts to ask me to abort? Is that an indication that there's some type of error with the dump file or the restoring process?


----------



## hockey97 (Feb 15, 2014)

I just want to add something about when I run `restore -urf /mnt3/da0s1a.dump`. Here are the errors I get after it runs for about ten min*ute*s:

```
./usr/home/bob/.gconfd/saved_state: (inode 98895223) not found on tape
expected next file 15143956, got 13
./ib/libc.so.7: cannot create file : operation not permitted
./usr/bin/login: cannot create file: operation not permitted
```
*I*t gives a bunch of the operation not permitted errors. Then towards the end it asks to mount tape volume 2. It then says type none if there's no other tape. Which I  type none. It *T*then shows this:

```
warning: cannot create hard link ./sbin/rrestore->./sbin/restore: no such file or directory.
```

I get many lines like this. Then like 20 min*ute*s later I get the abort questions. I just used the command: `chflags noschg /sbin/`. I didn't stop those errors from showing up. I still get the same results.


----------



## wblock@ (Feb 16, 2014)

The flags are set on individual files, not the directory.  So `chflags noschg /usr/bin/login` and so on.

There are half a dozen or so in /sbin and some also in /usr/sbin.  `ls -lo` shows them.


----------



## hockey97 (Feb 21, 2014)

wblock@ said:
			
		

> The flags are set on individual files, not the directory.  So `chflags noschg /usr/bin/login` and so on.
> 
> There are half a dozen or so in /sbin and some also in /usr/sbin.  `ls -lo` shows them.



Is there a command that can change those flags for all the files in the folder?  I did this manually for the errors:

```
/ib/libc.so.7: cannot create file : operation not permitted
./usr/bin/login: cannot create file: operation not permitted
```
I didn't do it for the 
	
	



```
cannot hard link
```
 error ones. However, those errors about operation not permitted  no longer show up after changing the flags.  The problem I have is that doing it for each individual file is a pain in the butt. I am sure there's a command to change the flags of all the files inside a folder.The errors about the hardlinks are long and I cannot actually read most of them because the terminal keeps generating the new errors where the previous ones ends up going off screen. I am guessing I can use the pause/break key on the keyboard to stop the process correct? So, I can actually read the messages on the screen? Let me know the command that I should be typing to change the flags for all the files that reside in that folder or directory.


----------



## wblock@ (Feb 21, 2014)

The flags on a group of files can be changed with pattern matching: `# chflags noschg /usr/bin/*`. That is not particularly safe, those flags are there for a reason.  It's better to list just the files to change, the ones that will be overwritten: `# chflags noschg /usr/bin/login /usr/bin/chfn /usr/bin/crontab ...`.


----------



## hockey97 (Feb 21, 2014)

wblock@ said:
			
		

> The flags on a group of files can be changed with pattern matching:
> `# chflags noschg /usr/bin/*`
> 
> That is not particularly safe, those flags are there for a reason.  Better to list just the files to change, the ones that will be overwritten:
> `# chflags noschg /usr/bin/login /usr/bin/chfn /usr/bin/crontab ...`



Yeah, I already did that for those. What I am talking about is the the remaining errors:

```
warning: cannot create hard link ./sbin/rrestore->./sbin/restore: no such file or directory.
```

But is there a way to slow down the terminal or pause it? Because these create hard link errors. It shows up on the screen within seconds and there's many of them. Where it would quickly fill up the screen and then some of it will go off the screen. Or is there a way to navigate thru through the fixit shell?  Can I go back to previous messages that was printed out to the screen?

Plus the errors later on are asking me 
	
	



```
abort? [y/n]
```
Most of those errors are in the documentation folders. It's mainly replacing the Freebsd FreeBSD handbook.


----------



## wblock@ (Feb 21, 2014)

Look at restore(8).  -x may help by restoring only the directories needed.  -y sounds like it is for skipping tape errors, but might also skip the hard link errors.


----------



## hockey97 (Feb 22, 2014)

wblock@ said:
			
		

> Look at restore(8).  -x may help by restoring only the directories needed.  -y sounds like it is for skipping tape errors, but might also skip the hard link errors.



I just tried it. I typed this in: `restore -yurf /mnt3/da0s1.dump`. This still showed the hard link errors and no such directory or file errors. However, it automated the questions part by saying no to each abort question. I let it run and after it stops it brings me back to the terminal/shell. I  then restart the server and tried to boot off the hard drive and it still cannot boot off the hard drive itself. I don't get why it's not booting anything.  :q


----------



## wblock@ (Feb 22, 2014)

Possibly unrelated to the restore.  Boot code has to be installed on a fresh disk, and if you use MBR slices and FreeBSD partitions, boot code also needs to be installed into the label area.  See the second half of this article: Disk Setup On FreeBSD.  If you have other questions that are not related to restore(8), please start a new thread.


----------



## hockey97 (Mar 1, 2014)

wblock@ said:
			
		

> Possibly unrelated to the restore.  Boot code has to be installed on a fresh disk, and if you use MBR slices and FreeBSD partitions, boot code also needs to be installed into the label area.  See the second half of this article: Disk Setup On FreeBSD.  If you have other questions that are not related to restore(8), please start a new thread.



Never mind*. I* found the issue was with the BIOS not recognizing the hard drive as bootable. I had to reconfigure the BIOS to recognize the hard drive as a boot drive. I  installed FreeBSD 8.4 on the hard drive and made a clean install. It still didn't boot. I then checked in the BIOS and found out there was the issue why my system wouldn't boot. It didn't recognize the hard drive to be set to a boot-able drive.


----------



## hockey97 (Mar 5, 2014)

wblock@ said:
			
		

> Possibly unrelated to the restore.  Boot code has to be installed on a fresh disk, and if you use MBR slices and FreeBSD partitions, boot code also needs to be installed into the label area.  See the second half of this article: Disk Setup On FreeBSD.  If you have other questions that are not related to restore(8), please start a new thread.



The hard drive boots now. If I restore mbr.img  to the hard drive. It then no longer becomes bootable. However, when I  destroy and redo the hard drive and leave the MBR alone I do a restore and I can see most of the files are on the hard drive and are correct. However, no servers can run properly. It has many errors. Like for apache22 it talks about the configuration  file not being readable. I  still get the same error messages that I previously stated in the other posts. I still get those hard link errors asking if I would like to abort. I no longer get those starting errors I talked about.  The only error messages I get are just the hard link errors showing me the parent file and the sibling file and asking if I would like to abort. 

However, when I start the server and it boots the hard drive. I can only load the shell/terminal screen. I had GNOME installed on the system and I cannot load that or run GNOME. Most server software like apache22 won't run. The only thing that works is my mail server. My database software is messed up.  I am thinking those hard link errors have something to do with it. I can tell every file is there on the hard drive. It's not I guess how everything is linked together is what seems to be failing.  The  hard link errors  are shown on the screen fast, meaning it doesn't last long. I notice a few links talking about the directory of *W*ebmin which is what I use to manage all my servers and database myself and mail server etc. 

Do you think those hard link errors are important? How would I fix those errors?


----------



## wblock@ (Mar 5, 2014)

This is long past a restore and run situation.  Install a fresh system on a new drive.  Copy the intact data files from the restore on the old drive to the new drive.


----------



## hockey97 (Mar 10, 2014)

wblock@ said:
			
		

> This is long past a restore and run situation.  Install a fresh system on a new drive.  Copy the intact data files from the restore on the old drive to the new drive.



Thanks for the help. I figured out the problems and issues. The reason I got those errors was because it wasn't  actually transferring all the data. I had a dump of 3.9 gigs and it's because I used the FAT32 file system. If kept failing and on windows I used winrar to decompressed the .bz2 file.  Well it did a crappy job and had the dump file at 3.9. So, most of that dump files did transfer to my server hard drive. It just wasn't a full dump. I then used 7zip for windows. This uncompressed the .bz2 to a 11.8 gigs. I  had to use the NTFS filesystem on my external hard drive. This lead to another issue where it won't actually mount the device. I fiddled around and ended up figuring out that I needed to manually load in the NTFS module for the kernel. I finally got around to it and after doing this. I was able to mount the device and then try the restore. This time I didn't do any commands other then just a `resture --yurf /mnt3`  Everything ended up working. I did have 3 files that gave me a permission error. However, the restore all went great. I now got my working system back.  :i  :beergrin  :beer


----------

