LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   restore file or dir from dump file (https://www.linuxquestions.org/questions/linux-newbie-8/restore-file-or-dir-from-dump-file-225846/)

brumela 09-02-2004 03:53 PM

restore file or dir from dump file
 
Is it possible to restore just single file or directory from a dump file?
Which switch should I use?

regards brumela

MasterC 09-03-2004 04:04 AM

Could you be more specific? How did you get the dump file, which application did you use to create it, what directory or file are you trying to retrieve... :) A dump file could mean a variety of things.

Cool

brumela 09-03-2004 12:55 PM

hmm,... yes you are right, I created my dump file with dump command, like this
Quote:

/sbin/dump -j -f /home/bruma/backup/rootfs.dump /bin /dev /lib /misc /sbin /var /boot /etc /initrd /opt /root /usr

MasterC 09-08-2004 04:31 AM

Well it looks like there is a restore command that comes with the dump package (don't have it, simply reading what's available on the net) and if it's run in interactive mode you can restore single directories.

Cool

ddbtek 01-18-2023 10:56 AM

yes, you can restore a single file from a "dump"
 
I have used dump/restore throughout my 40+ year career as a *NIX/SA and still use it today.

dump/restore were the old ways of backing up systems that old *NIX hacks used. Many UNIX SA's still use them today because they are complete. Most people do not use dump today because they are unaware or have forgotten, but it works and works very well.

If you have a backup script that runs monthly via root cron (server_dump.sh) to back up a server like this (level 0 dump):

Code:

#!/bin/bash

thedate=`/bin/date '+%m%d%y'`;
host=`uname -n`;
path="/backups/servers/"$host;
fname=$path"/"$host"_"$thedate"_"$$".dump";
date
mkdir -p $path

echo "Level 0 dump to:  $fname";
/usr/bin/nice /sbin/dump -0u -M -z -f $fname /

# no compressing because it only compresses by .2 percent, backup is already compressed
#/usr/bin/nice gzip -v $fname

date
echo "done."

You can do a full restore with /sbin/restore by creating the blank filesystem, mountaing it, switching to it and running /sbin/restore (these are linux commands but similar to solaris, aix operation, etc.)

Code:

mke2fs /dev/sda1
mount /dev/sda1 /mnt
cd /mnt
restore rf /dev/st0

However, if you want to restore a single file, as you have asked, it is done like this:

(the following command runs "restore" in an interactive mode so it doesn't do anything without asking):
root@mon1:/backups/servers/prod-db-01# restore -ivf <full pathname of dump file>

Once "restore" opens and reads the header, it will present you with a prompt: "restore >", at this prompt you can type various commands that let you traverse the directory paths within the dump, list directories, restore files, etc.)

Code:

Verify tape and initialize maps
Input is from a local file/pipe
Input block size is 10
Dump tape is compressed.
Dump  date: Sun Jan  1 00:04:01 2023
Dumped from: the epoch
Level 0 dump of / on prod-db-01:/dev/mapper/prod--db--01--vg-root
Label: none
Extract directories from tape
Initialize symbol table.
restore >

At the "restore >" prompt you can type "ls" and list the current root directory of the dump:

Code:

restore> ls[ENTER]

.:
      2 ./            2621441 lib/          19922945 san1/
      2 ../            1835009 lib64/        20447233 sbin/
10092545 backup/      24117249 localbackups/ 26476545 snap/
      18 backups@            11 lost+found/  25034753 srv/
24903681 bin/          2359297 media/        9175041 sys/
 4718593 blob/          6553601 mnt/          16252929 tmp/
 2883585 boot/              14 obins@        15466497 usr/
 3014657 dev/          11534337 opt/          1572865 var/
      13 dump@        26738689 proc/              17 vmlinuz@
19398657 etc/          3145729 root/              16 vmlinuz.old@
23592961 home/        21233665 run/

Now, the above happened to be a linux system but it works the same on solaris, aix, etc.

Please review the man page for "restore". The linux version was written by the gentlman that wrote the original version of "dump/restore" so it's complete.

I hope this works for you.

Thanks,
David

TB0ne 01-18-2023 10:58 AM

Quote:

Originally Posted by ddbtek (Post 6405255)
I have used dump/restore throughout my 40+ year career as a *NIX/SA and still use it today.
dump/restore were the old ways of backing up systems that old *NIX hacks used. Many UNIX SA's still use them today because they are complete. Most people do not use dump today because they are unaware or have forgotten, but it works and works very well. If you have a backup script that runs monthly via root cron (server_dump.sh) to back up a server like this (level 0 dump):
Code:

#!/bin/bash
thedate=`/bin/date '+%m%d%y'`;
host=`uname -n`;
path="/backups/servers/"$host;
fname=$path"/"$host"_"$thedate"_"$$".dump";
date
mkdir -p $path

echo "Level 0 dump to:  $fname";
/usr/bin/nice /sbin/dump -0u -M -z -f $fname /

# no compressing because it only compresses by .2 percent, backup is already compressed
#/usr/bin/nice gzip -v $fname

date
echo "done."

You can do a full restore with /sbin/restore by creating the blank filesystem, mountaing it, switching to it and running /sbin/restore (these are linux commands but similar to solaris, aix operation, etc.)
Code:

mke2fs /dev/sda1
mount /dev/sda1 /mnt
cd /mnt
restore rf /dev/st0

However, if you want to restore a single file, as you have asked, it is done like this:(the following command runs "restore" in an interactive mode so it doesn't do anything without asking): root@mon1:/backups/servers/prod-db-01# restore -ivf <full pathname of dump file>

Once "restore" opens and reads the header, it will present you with a prompt: "restore >", at this prompt you can type various commands that let you traverse the directory paths within the dump, list directories, restore files, etc.)
Code:

Verify tape and initialize maps
Input is from a local file/pipe
Input block size is 10
Dump tape is compressed.
Dump  date: Sun Jan  1 00:04:01 2023
Dumped from: the epoch
Level 0 dump of / on prod-db-01:/dev/mapper/prod--db--01--vg-root
Label: none
Extract directories from tape
Initialize symbol table.
restore >

At the "restore >" prompt you can type "ls" and list the current root directory of the dump:
Code:

restore> ls[ENTER]
.:
      2 ./            2621441 lib/          19922945 san1/
      2 ../            1835009 lib64/        20447233 sbin/
10092545 backup/      24117249 localbackups/ 26476545 snap/
      18 backups@            11 lost+found/  25034753 srv/
24903681 bin/          2359297 media/        9175041 sys/
 4718593 blob/          6553601 mnt/          16252929 tmp/
 2883585 boot/              14 obins@        15466497 usr/
 3014657 dev/          11534337 opt/          1572865 var/
      13 dump@        26738689 proc/              17 vmlinuz@
19398657 etc/          3145729 root/              16 vmlinuz.old@
23592961 home/        21233665 run/

Now, the above happened to be a linux system but it works the same on solaris, aix, etc. Please review the man page for "restore". The linux version was written by the gentlman that wrote the original version of "dump/restore" so it's complete.

Good post; but I think that after *NINETEEN YEARS*, the OP has moved on.

ddbtek 01-18-2023 11:54 PM

after 19 years
 
There are lot of UNIX admins still working on old systems and may not know how to use the dump/restore command. I found this thread because I was double-checking my memory. I think the important thing is the sharing of information. Right?

TB0ne 01-19-2023 08:20 AM

Quote:

Originally Posted by ddbtek (Post 6405357)
There are lot of UNIX admins still working on old systems and may not know how to use the dump/restore command. I found this thread because I was double-checking my memory. I think the important thing is the sharing of information. Right?

Right; which is why I said, "Good post". But I'd doubt it's being used much (if at all) these days, since a system that only has dump/restore available probably wouldn't be in active use any longer. Most environments are using network backup solutions these days.


All times are GMT -5. The time now is 12:07 AM.