Operating System - HP-UX
1823920 Members
3262 Online
109667 Solutions
New Discussion юеВ

how to use tar command to run differential backup?

 
SOLVED
Go to solution
Jan Shu
Regular Advisor

how to use tar command to run differential backup?

Hi All,

I use tar command to run daily full backup on file systems on a SAS9 DI server. My users would like to have real-time backup on their SAS data folders. How to use tar command to run differential backup so it won't take longer time copy data? Thanks.

Regards,
Jan Shu
9 REPLIES 9
Steven Schweda
Honored Contributor
Solution

Re: how to use tar command to run differential backup?

I know of no built-in incremental backup
capability in the standard HP-UX "tar"
program. Have you considered using "cpio" or
GNU "tar"?

If you can devise a "find" (or other) command
which will identify the files you wish to
archive, then you can feed those names into
"tar" (or, perhaps more easily, into "pax").

It's often helpful to disclose your OS (and
its version).
James R. Ferguson
Acclaimed Contributor

Re: how to use tar command to run differential backup?

HI Jan:

The HP-UX proprietary (but free) 'fbackup'/'frecover' utilities allow you to setup incremental backups. Be advised that they are deprecated beginning with 11.31, however ( a real shame, in my opinion ).

Regards!

...JRF...
Jan Shu
Regular Advisor

Re: how to use tar command to run differential backup?

Hi Steven,
Thanks for the reply. This server has HPUX 11.23 OE.

Jan Shu
Regular Advisor

Re: how to use tar command to run differential backup?

Hi James,
Thanks for the info. I will take a look the fbackup. I think it is in SAM.
Steve Post
Trusted Contributor

Re: how to use tar command to run differential backup?


You get a list of files via

find / -print > mybiglist.txt

Now what if you had a file from the last backup time? Like.... /utl/backups/lasttime

find / -newer /utl/backups/lasttime -print > mybiglist_inc.txt

So....
Level 0 backup.(everything)
1. make a list of all files.
2. backup from the list.
3. make a file called /utl/backups/lasttime via the touch command.

Level 1 backup.(everything since the last backup)
1. make a list of all files newer than "lasttime".
2. backup from the list.
3. make a file called /utl/backups/lasttime via the touch command.

Note I didn't mention the tar syntax? I use cpio.
It would be....
cat mybiglist.txt | cpio -odumvc > /dev/rmt/0m

Tar can do this..uh...right?

Jan Shu
Regular Advisor

Re: how to use tar command to run differential backup?

Hi Steve P.,
Thanks for the find and cpio commands. How to restore data from above backup files? Do I restore from the backup_0 and then the backup_newer? Thanks.

Regards,
Jan
Steve Post
Trusted Contributor

Re: how to use tar command to run differential backup?

First off, if I were you, I would look into fbackup and frecover. Everyone likes these. They are fast and simple. The bad news about it is that it is one backup per tape. The good news is it is fast and simple to backup and recover. I replaced my cpio backups with this.

To backup with cpio to a tape drive called /dev/rmt/0m. I'll assume you have a full backup on a tape, and an incremental backup on the same tape, after the full.

find / -print | cpio -odumvc > /dev/rmt/0mn


To recover file /tmp/junkdir/billybob.txt from the first, full backup:
1. The proper path of billybob.txt needs to be known. If you try to recover ./tmp/junkdir/billybob.txt, it won't find it. If you try just billybob.txt, it won't find it.
So you do this....
cpio -itdumvc < /dev/rmt/0m > cpio.filelist
Note the "t" here. This t is for "table of contents". It's a listing of the files.
Then...
grep billybob.txt cpio.filelist
This shows it as /tmp/junkdir/billybob.txt
I always worry about recovering from root. So I don't do it. I recover on a big junk directory and move it after the fact.
cd /bigjunkdir
cpio -idumvc < /dev/rmt/0m /tmp/junkdir/billybob.txt

This makes file /bigjunkdir/tmp/junkdir/billybob.txt
I next copy billybob.txt to its proper place and get rid of directory /bigjunkdir/tmp.


What about incremental recovery? It's still recovery. Perhaps you want incremental and full backups on the same tape?
You can't do that with fbackup/frecover. You can do that with cpio.
mt -f /dev/rmt/0mn rewind
this rewinds the tape
mt -f /dev/rmt/0mn fsf 1
This moves the tape past the first backup on the tape. I'll assume it is a full backup.
At this point, I'll assume you have your incremental backup.
Run that "cpio -itdumvc < /dev/rmt/0mn" to get a list of what is on the second backup on the tape, aka the incremental backup.
Note the "n" in /dev/rmt/0mn tells the tape to NOT rewind when it is done.

Ok......
cd /bigjunkdir
mt -f /dev/rmt/0mn rewind
mt -f /dev/rmt/0mn fsf 1
cpio -itdumvc < /dev/rmt/0mn > filelist
grep billybob.txt filelist
Now I know I want to recover "/tmp/junkdir/billybob.txt"
mt -f /dev/rmt/0mn rewind
mt -f /dev/rmt/0mn fsf 1
cpio -idumvc < /dev/rmt/0mn /tmp/junkdir/billybob.txt

Now the incremental billybob.txt file showed up in /bigjunkdir/tmp/junkdir.
mt -f /dev/rmt/0mn rewind
Now the tape is rewound.

The thing is...you need to know that the first thing on the tape is the full backup with cpio, and the second thing is the incremental backup with cpio. You can find this out with that "mt" command and "cpio -idtumvc" command.

Now....forget about cpio and use fbackup/frecover. You can only store one backup on a tape. But it is easier and faster. Let me know if you want some help on that. I think I have typed way WAY too much here!

Jan Shu
Regular Advisor

Re: how to use tar command to run differential backup?

Hi Steve P.
Thanks for the info. I will try this on my development server. Thanks.

Regards,
Jan
Steve Post
Trusted Contributor

Re: how to use tar command to run differential backup?

feel free to ask more questions. I'll have your forum thread notify me if more is added.

And REALLY now....
fbackup and frestore is a better way to go.