unattended disk clone

Chris Whitehouse chris at childeric.freeserve.co.uk
Fri Nov 3 00:04:32 GMT 2006

Adrian Wontroba wrote:
> On Wed, Nov 01, 2006 at 11:49:19PM +0000, Spadge wrote:
>> Chris Whitehouse wrote:
>>> I'm running dump/restore in a script to clone disks. For each partition 
>>> restore stops and asks me if I want to
>>> set owner/mode for '.'? [y/n]
>>> Can I somehow avoid this prompt so that the script is completely 
>>> automatic? I'm sure the answer ought to be simple and obvious but I 
>>> can't see it.
>>      -r      Restore (rebuild a file system).  The target file system 
>> should be made pristine with newfs(8), mounted and the user cd(1)'d into 
>> the pristine file system before starting the restoration of the initial 
>> level 0 backup.  If the level 0 restores successfully, the -r flag may 
>> be used to restore any necessary incremental backups on top of the level 
>> 0.  The -r flag precludes an interactive file extraction and can be 
>> detrimental to one's health if not used carefully (not to mention the disk).
>> Is that what you're doing? What flags are you using in the dump/restore 
>> script?
> This fragment from a make file (don't ask!) works without asking
> questions:
> dump -L -C 32 -0 -f- $$f | (cd /mnt$$f; restore -r -f- ) ; \
> A quick look at the source for restore makes me think that it will only
> ask this question if running with -i or -x.

What does $$f do? $$ is the pid of the invoked shell from man sh(1).

My script includes
mount /dev/adwhatever /mnt
cd /mnt
dump 0afL - / | restore xf -

and similar for /var, /tmp, /usr, which has worked completely reliably 
but I have to answer the prompt. I just tried
dump 0afL - / | restore rf -
and got a message "expected next file 16573, got 8756". I think this is 
what is referred to in the -L option in dump's man page. I've tried 
/.snap set to drwxrwx---  2 root  operator which is what the man page 
says (0770?) and drwxrwxr-x which is what it is set to on an older but 
untouched system but I still get the same message.

I also tried
dump -L -C 32 -0 -f- / | restore -r -f-
and got the same "expected next file..." message whereas
dump -L -C 32 -0 -f- / | restore -x -f-
behaved but I got the prompt.

Am I still missing something? Otherwise I either have to live with not 
quite automatic or warning messages. I will probably opt for the former, 
or maybe try rsync.

I'll have another read of the man page in the next day or so but if 
anyone can tell me what is going wrong I'd be grateful.


More information about the Ukfreebsd mailing list