Re: Usage of restore

2013-01-28 Thread Warren Block

On Mon, 28 Jan 2013, Ralf Mardorf wrote:


I don't understand how to use the restore command.

root@freebsd:/mnt/dump # restore -v -t 
dump-9.1-RELEASE-20130123_193142-usr_f.dump
Verify tape and initialize maps
/dev/sa0: No such file or directory


sa0 is the tape device, used by default if -f is not specified.


root@freebsd:/mnt/dump # restore -v -t -f 
dump-9.1-RELEASE-20130123_193142-usr_f.dump


That is the right way to list the contents.


Verify tape and initialize maps
Tape block size is 32
Tape is not a dump tape


Except...


dump -0Launf - $rootdir_a | bzip2  $dump_path-roota.dump


The files that are called dump files are actually compressed with bzip2. 
So they need to be uncompressed.  It would be good to change the backup 
script to name the files .dump.bz2 or something similar.


Untested, but overconfidently:

# bzcat dump-9.1-RELEASE-20130123_193142-usr_f.dump | restore -v -t -f -


For reference:
http://www.wonkity.com/~wblock/docs/html/backup.html
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Usage of restore

2013-01-28 Thread Polytropon
On Mon, 28 Jan 2013 15:53:25 +0100, Ralf Mardorf wrote:
 Hi :)
 
 I don't understand how to use the restore command.

The answer is in man restore. :-)



 root@freebsd:/mnt/dump # restore -v -t  
 dump-9.1-RELEASE-20130123_193142-usr_f.dump
 Verify tape and initialize maps
 /dev/sa0: No such file or directory

Correct. The program defaults to a tape drive /dev/sa0 to read
dumps from. You need to specify -f file if you want to read
from a file instead.

Also: Note that restore will usually restore the files in the
current (!) directory, so you need to cd to where you want to
extract the dump to.



 root@freebsd:/mnt/dump # restore -v -t -f  
 dump-9.1-RELEASE-20130123_193142-usr_f.dump
 Verify tape and initialize maps
 Tape block size is 32
 Tape is not a dump tape

Did you create the dump in some non-default format?



 FWIW the dump files are on a ext3 fs. I know that I don't need to backup  
 /tmp.

It shouldn't matter what filesystem the dump files are stored
on. It's just important they are in the correct format.



 The backups were done by this script, perhaps I've done something wrong:
 
 root@freebsd:/mnt/dump # cat /root/dump.sh
 #! /bin/bash

Ern... two things: Do you _really_ have /bin/bash on FreeBSD?
I know this is possible.

And do you use any bash-specific features in your script? If
not, why not use /bin/sh, the universally accepted standard? :-)



 # bash dump.sh
 
 dumpstart=$(date +%Y%m%d_%H%M%S)
 dump_path=/mnt/dump/dump-$(uname -r)-$dumpstart
 rootdir_a=/dev/ad4s1a
 usr_dir_f=/dev/ad4s1f
 var_dir_d=/dev/ad4s1d
 tmp_dir_e=/dev/ad4s1e
 
 #mkdir $dump_path
 dump -0Launf - $rootdir_a | bzip2  $dump_path-roota.dump
 dump -0Launf - $usr_dir_f | bzip2  $dump_path-usr_f.dump
 dump -0Launf - $var_dir_d | bzip2  $dump_path-var_d.dump
 dump -0Launf - $tmp_dir_e | bzip2  $dump_path-tmp_e.dump
 echo Started: $dumpstart
 echoDone: $(date +%Y%m%d_%H%M%S)
 
 exit 0

Looks correct, but read carefully:

 dump -0Launf - $usr_dir_f | bzip2  $dump_path-usr_f.dump

Now compare again:

restore -v -t -f dump-9.1-RELEASE-20130123_193142-usr_f.dump

Do you notice bzip is involved in the creation step, but not
in the reading step?

You need to apply uncompression first so that restore will
have data in .dump format (instead of .dump.bz2 which it
obviously cannot understand). Verify:

file dump-9.1-RELEASE-20130123_193142-usr_f.dump

So using proper file extensions can prevent confusion. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Usage of restore

2013-01-28 Thread Ralf Mardorf

On Mon, 28 Jan 2013 16:54:29 +0100, Polytropon free...@edvax.de wrote:

The answer is in man restore. :-)


No it isn't ;). I did read it.

This was a Wald'n'Bäume situation. Even if I would have add a .bz2, I
would have missed it, since on Linux I .tar.bz backups and it's more
automated to extract a .tar.foo. However, I should add .bz2 in the future.


Ern... two things: Do you _really_ have /bin/bash on FreeBSD?
I know this is possible.

And do you use any bash-specific features in your script? If
not, why not use /bin/sh, the universally accepted standard? :-)


No /bin/bash,

# ls /usr/local/bin/bash
/usr/local/bin/bash

I run bash file instead of sh file, IIRC I already had an issue when  
writing a script and running sh file.


I use it, since I use it on Linux too, another shell might cause issues,  
if I continue writing this script or if I should write another script.  
Btw. I was an Assembler coder in the 80s and don't have much knowledge how  
to write shell scripts, if I need something I search for it. I'm using  
*NIX as OS for audio productions and for the Internet, I'm not interested  
in programming anymore, I only do what's needed, *NIX OS are a tool for  
me. Philosophy about POSIX isn't a religion for me.


I thought /bin/sh is a link to another shell.

Regards,
Ralf
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

Re: Usage of restore

2013-01-28 Thread Polytropon
On Mon, 28 Jan 2013 17:28:10 +0100, Ralf Mardorf wrote:
 On Mon, 28 Jan 2013 16:54:29 +0100, Polytropon free...@edvax.de wrote:
  The answer is in man restore. :-)
 
 No it isn't ;). I did read it.

Eáu còntrair! :-)

 -f file
 Write the backup to file; file may be a special device file like
 /dev/sa0 (a tape drive), /dev/fd1 (a floppy disk drive), an ordi-
 nary file, or `-' (the standard output).  Multiple file names may
 be given as a single argument separated by commas.  Each file
 will be used for one dump volume in the order listed; if the dump
 requires more volumes than the number of names given, the last
 file name will used for all remaining volumes after prompting for
 media changes.  If the name of the file is of the form
 ``host:file'', or ``user@host:file'', dump writes to the named
 file on the remote host using rmt(8).  The default path name of
 the remote rmt(8) program is /etc/rmt; this can be overridden by
 the environment variable RMT.

You could even set $TAPE to the file name and omit -f. :-)



 This was a Wald'n'Bäume situation.

That's possible.



 Even if I would have add a .bz2, I
 would have missed it, since on Linux I .tar.bz backups and it's more
 automated to extract a .tar.foo.

But .tar.bz != .dump and != dump.bz (different programs: tar and
dump are working differently).



 However, I should add .bz2 in the future.

At least this is a comfortable way to avoid confusion and know
file content by simply looking at its name.



  Ern... two things: Do you _really_ have /bin/bash on FreeBSD?
  I know this is possible.
 
  And do you use any bash-specific features in your script? If
  not, why not use /bin/sh, the universally accepted standard? :-)
 
 No /bin/bash,
 
 # ls /usr/local/bin/bash
 /usr/local/bin/bash
 
 I run bash file instead of sh file, IIRC I already had an issue when  
 writing a script and running sh file.

Okay, that is a fully valid solution, in that case #!/bin/bash
is ignored.

But just think about a typical worst case scenario: You
have a script that requires bash, and you need to apply it
it SUM with /usr unmounted, and you accidentally do not have
a statically linked /bin/bash. Wouldn't it be much more
convenient to rely on the /bin/sh default scripting shell?

Maybe if you review your script, you can find out what
bash-ism is employed and turn it into a valid sh equivalent
while keeping the intended functionality. At a first glance,
I don't see anything sh can't do.



 I use it, since I use it on Linux too, another shell might cause issues,  
 if I continue writing this script or if I should write another script.  

Interoperability for scripting is hard in regards of Linux,
where sh isn't bash, and sometimes bash isn't bash either. :-)



 I thought /bin/sh is a link to another shell.

Sometimes it is. Sometimes not.

-r-xr-xr-x  1 root  wheel  115348 2011-08-21 20:23:20 /bin/sh*

On FreeBSD, /bin/sh is technically ash (This code is derived
from software contributed to Berkeley by Kenneth Almquist.,
see /usr/src/bin/sh/main.c), a replacement for the traditional
Bourne shell whose name it inherits. It's a real binary, not
a link.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Usage of restore

2013-01-28 Thread Ralf Mardorf

Another issue.

# bunzip2  dump-9.1-RELEASE-20130123_193142-usr_f.dump | restore -t -f -

does work, but the output doesn't show the owner and I want to get some  
output I can use with mtree, to fix a broken owner for some files.


Regards,
Ralf

PS: man restore doesn't tell me, that I missed to extract the compressed  
archive ;).

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org