1850957 Members
6415 Online
104056 Solutions
New Discussion

Re: Backup with TAR

 
SOLVED
Go to solution
Mauro_8
Frequent Advisor

Backup with TAR

Hi,

I have this configuration

Filesystem Use% Mounted on
/dev/sda1 80% /
/dev/sdb1 84% /home
/dev/sda4 76% /opt

and want to do a full backup for this machine. So , if I do "tar cvf /dev/st0 /* " it will backup all files in this machine ?

Regards,
Mauro
18 REPLIES 18
Alexander M. Ermes
Honored Contributor
Solution

Re: Backup with TAR

Hi Mauro.
I would suggest cpio.

#!/sbin/sh
# set -x
today_=`date +'%y-%m-%d'`; export today_
#
LOG1=/usr/tmp/cpio_${today_}.1st; export LOG1
#
PATH=$PATH:/usr/local/bin
export PATH
exec > /usr/tmp/cpio_${today_}.log 2>&1
#
#
find / -depth -print | cpio -ocBv > /dev/rmt/0m 2>> ${LOG1} &
first_cpio=$!; export first_cpio
#
wait $first_cpio

if test $? -ne 0; then
echo "Full Offline Backup did not complete successfully!"
fi
echo "Time is: `/bin/date`"
echo "Time is: `/bin/date`"
echo "Time is: `/bin/date`" >> ${LOG1}
~


END OF SAMPLE.

Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Stefan Farrelly
Honored Contributor

Re: Backup with TAR

Yes, your tar command will backup everything.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Steven E. Protter
Exalted Contributor

Re: Backup with TAR

cd /
tar cv *

tar defaults to the first tape device.

This will back up every file on the box that is on a mounted filesystem.

It will not in any way back up the LIF area or other important boot files. Its value is to back up data only up to 2 GB, 8 GB if you have the latest HP tar patch.

If you want a usable bootable tape that can restore a working system, make_tape_recovery

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Mauro_8
Frequent Advisor

Re: Backup with TAR

Hi,

My full backup should have 20GB and I am getting problems while running it because some file system did not appears in my tape.

I have a lot of files with 200MB. Is it a problem when using TAR ?

Cheers,
Mauro
Ravi_8
Honored Contributor

Re: Backup with TAR

Hi,

tar cvf /
will backup the full system as / is the mount point for all file systems
never give up
Mauro_8
Frequent Advisor

Re: Backup with TAR

Hi,

How can I restore with cpio ?

I will test it.

Cheers,
Mauro
Ravi_8
Honored Contributor

Re: Backup with TAR

Hi,

tar can handle upto 8GB, since your data is more than that, i would recommend using make_tape_recovery (ignite backup)
never give up
Ravi_8
Honored Contributor

Re: Backup with TAR

Hi,

if the file is in cpio format, to extract
#cpio -icdv < file_name
never give up
Mauro_8
Frequent Advisor

Re: Backup with TAR

Hi,

Can I restore only any files ? For example, /home/mauro/backup/file_1.txt.

With the command listed I think I am gong to restore all files on tape. Am I right ?


Cheers,
Mauro
Tomek Gryszkiewicz
Trusted Contributor

Re: Backup with TAR

You can restore one file:
tar xv /path/to/the/file
Piergiacomo Perini
Trusted Contributor

Re: Backup with TAR

Hi,

with cpio utility, in order to
restore one file, try this :

#cpio -icdv /home/mauro/backup/file_1.txt < file_name

Hih
Mauro_8
Frequent Advisor

Re: Backup with TAR

Hi,

cpio works fine but when I try to list the files on tape using cpio -ivt < /dev/st0 it shows the files with some strange characters. The blank space is shown "\" or the letter ?? (portuguese) has problems, for example, the file "/home/mauro/Finan??as" appears "/home/mauro/Finan\347as". What should it be ? When I want to restore can I use :
cpio idv "/home/mauro/Finan??as" or I should use "/home/mauro/Finan\347as" ?

Thanks once more,
Mauro
Caesar_3
Esteemed Contributor

Re: Backup with TAR

Hello!

I think that you should use tar,
when you made tar for / it arcive all the
files and not check for LVs that is mounted.

Caesar
Bill Hassell
Honored Contributor

Re: Backup with TAR

tar will handle thousands of gigabytes of data. It will NOT backup any file that is larger than 2Gb. A recent HP-UX patch for tar extends this limit to 8Gb for a single file (still no limit on the total backup). However, the resultant tar tape (with files larger than 2Gb) cannot be restored on any other version of Unix without this special version of tar. And note that tar cannot be used to restore a system that cannot boot. For HP-UX, you need to use make_tape_recovery from the Ignote/UX package.

Note that the above device files for disks and tape do not look like HP-UX but the comments about standard tar still apply.


Bill Hassell, sysadmin
Huc_1
Honored Contributor

Re: Backup with TAR

hello Mauro

I think you are in the wrong place
/dev/sda1 and /dev/st0 are Linux not HP-UX

Still most of the info here above can be usefull,

On my linux I use dump to do full backup, from single user mode to backup each valid mount points in /etc/fstab, (valid that is not cd,nfs,floppys... etc)

like:

-------------------------------
#!/bin/bash
#mt -f /dev/st0 rewind
#dump -0a -f /dev/nst0 /
#dump -0a -f /dev/nst0 /usr
#dump -0a -f /dev/nst0 /home
#mt -f /dev/st0 rewind
-----------------------------

to restore (single user) you could do

#cd /
#mt -f /dev/st0 rewind
#restore -x -f /dev/nst0
This is for none interarive full restore

to restore on file in multi user mode do

#cd /usr
#mt -f /dev/st0 rewind
#mt -f /dev/st0 fsf 1
#restore -i -f /dev/nst0

this will put you in interactive restore with prompt

restore >

from there you can interactively mark file you want to restore ...

in this enviroment ls help extract are valid command just do a ? or help to get started

needless to say out have to test this on a test system before you fell at ease with the whole scenario.

I have put in place an automatic shutdown single user/backup/continue boot that those all the backup from crontab on given time/day.


You can also use tar as describe above, but to get a full/valid backup I would boot single user mode then do

#mt -f /dev/st0 rewind
#tar -cvzf /dev/st0 /

to restore full

boot installation cd start install until ask about partition of disk (do this if this is a new disk "you then better have saved your partition info some where safe") from there escape to shell "

this will get you to a shell prompt

from there you can restore with something like
(This is to long to describe in details)

tar -xvzf /dev/st0 "here your mount point.. something like /mnt/old_root

to restore individual files just do
#tar -xvzf /dev/st0 /usr/whatever_it_is

But I should stress that all this is from memory please test it and check, also there is a lot more to valid backup/restore then meet the eyes "like you must consider keeping in a safe place a report of you system's bios,disk,partions,network setup ... a long list" to begin to feel you could perhaps if you are lucky survive a main disater.

Hope you find some of this usefull

Jean-Pierre



Smile I will feel the difference
Mauro_8
Frequent Advisor

Re: Backup with TAR

Hi,

What I am doing wrong ?

My crontab file has:
0 3 * * * /home/test/backup.sh 2> /tmp/log.err || mail -s "Error backup.sh" my_email@domain.com < /tmp/log.err

And the file /home/test/backup.sh has:
find / -depth -print | cpio -ocBv > /dev/st0 2>> /tmp/log.err

I want to run this crontab and if an error occurs list it in /tmp/log.err then send this file to me by email, but it does not work and if no error occurs I want that while the files are copied to tape a list of the files on tape is created in /tmp/Log_files_on_tape.txt simultaneously. How can I redirect the output os the "find" command listed to this file (/tmp/Log_files_on_tape.txt) ?

Thanks once more,
Mauro

Mauro_8
Frequent Advisor

Re: Backup with TAR

Ooooops..

I forgot to say that probably the output of the find command is goint to /tmp/log.err !?

I really do not understand...

Thanks.

Cheers,
Mauro
Tim Sanko
Trusted Contributor

Re: Backup with TAR

Mauro,

The question is how large are your filesystems.
There is no limit ot how much you can put on a tape with tar or cpio, as you may span tapes etc.

If your filesystems are larger than 8 GB, scrap the tar idea. Go spend some money on
Microlite's BackupEdge. You can download a trial copy. It creates a tar archive, does compression, you can use tons of buffer size to speed the backup along. It also is the best tool for saving one's hash when necessary.

CPIO is fine also, but cpio I have used for years, and still hate it passionately, however it is usefull, and dump is good, for somethings. When a cpio archive has problems, start praying for God is the only one to help you when certain problems happen.

You are much more likely to have some trouble believing this but I spliced an old 150 MB from an Archive tape drive that had snapped. I opened the cartidge tape spliced it and lost only about 40 K of EDI data that we could redownload. We continued this recovery with a product named CTAR that was from Microlite. BackupEdge is the evolution of the same product, from the same company with 15 years of refinement.

I like BackupEdge as it creates a tar readable object. It also does incrementals, Masters,diferentials, and is cheap in price but terrific in quality.!!!

Tim