LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Weekly tape backup (https://www.linuxquestions.org/questions/linux-general-1/weekly-tape-backup-52046/)

WorldBuilder 03-27-2003 01:21 PM

Weekly tape backup
 
Hi all,

I am fairly new to the UNIX world in general. I have a server machine running Red Hat 8.0 Professional. Several weeks ago, I had a catastrophic problem, and had to rebuild the entire machine. At the time, I had a SUN DLT 4000 tape backup unit hooked up to it via an Adaptec 2940 SCSI card. Prior to that failure, I had never taken the time to LEARN how to backup the system, and therefore, I did not have a backup. My server is rebuilt now, and my number 1 priority is to get it backed up on a weekly basis. I want to back up EVERYTHING on the system onto 1 tape(40GB capacity tapes). However, like I said, I don't know anything about backing up right now, but I need to get it working. A friend of mine told me that there is a simple "tar" command I can use that will backup every single thing onto the tape. Can someone please explain to me what this might be? I am a newbie to this, and I intend on truly learning about backups soon, but I need to get it working before I learn. What I want to do is set the server to backup automatically, every Sunday night at midnight. I want it to do a full backup, and rewind to the beginning of the tape when it is done, that way, the next week's backup will overwrite it. Can anyone explain this to me step-by-step. You'd be a lifesaver!!! Thanks a million!

Chris B.

Crashed_Again 03-27-2003 01:48 PM

There are several ways to go about backups in Linux. I would suggest you check out the 'dump' command because it is the most widely used. I believe dump only supports ext2 file systems so if your using another file systems I don't think this would be an option.

Also you could simply create a cron job that backs up your system.

Here is a nice little tutorial to help you get started. Do a bit of googling for more information on backup options in Linux.

WorldBuilder 03-27-2003 01:56 PM

Thanks
 
Thanks for the info. I'll definitely look it over. I'm using the ext3 filesystem, so I don't think dump will work, either. Like I said, I'd like to get this working soon, using tar(if that's the easiest). I can learn about it all later. Ugh, I'm busy... What would be the command for the cron job you mentioned? Thanks, man!

Chris

PS. Let's say I do start getting a successful weekly backup, and my server does indeed, fail. Can't boot, can't do anything. How do I restore, then?!

Paul Johnson 03-28-2003 05:55 AM

Dump will work fine with ext3. (ext3 is actually just ext2 with a journalling file tacked on and different drivers).

To use tar to make a tape backup:

First identify your tape device. Its probably /dev/st0. You can find out by putting a tape in the drive and saying

mt rewind /dev/st0

If that starts the tape spinning then you have the right device. I'd suggest making a symbolic link

ln -s /dev/st0 /dev/tape

So from now on you just use /dev/tape in your scripts.

To back up everything just say

tar cvf /dev/tape /

Note that this will also back up any mounted file systems (including CD, floppy and NFS mounts). It will also list every file it backs up. To avoid this use "cf" instead of "cvf".

You can also do compression in tar by saying "cvfz" instead of "cvf". This uses gzip and is pretty CPU intensive. DAT drives generally have hardware compression, so you don't need to do it yourself.

To recover your data say

tar xvf /dev/tape

If you have lost everything then re-install a basic Linux from the distro, and then use that to run tar. If you want to be really clever then you could make a bootable floppy with just a minimal kernel, fdisk, mke2fs and tar on it. But its probably not worth the trouble.

Paul.

tracer 03-28-2003 08:09 AM

and how would you setup the cron job to run weekly?

Here is my situation...I have a 8 gig data drive I am backing up to a 20 gig tape. I want to (all on the same tape)

MONDAY - Backup 1
WEDNESDAY - BACKUP 2
SATURDAY - BACKUP 3

MONDAY2 - Overwrite Backup1
WEDNESDAY - Overwrite backup 2
SATURDAY - Overwrite Backup 3

where backup 1 , 2, 3 are directorys or parts of the tape. So on a single tape I always have the three most recent backups...(without having to change tapes...the box is rather inaccesible)

Paul Johnson 03-28-2003 08:37 AM

Ooof. Thats tricky. Tapes were never designed to be used that way. Its also a bad idea. Tapes are not useful backups when left in the machine. The whole point of tapes is that you can take them out of the machine and put them either in a fire safe or out of the building. If you leave the tape in permanently then you are only protected against a hard drive failure.

In fact I suspect you will find the cheapest way of meeting your requirements is to buy another hard drive. A 20 GB hard drive (tape sizes are doubled to allow for an assumed compression factor) will give you the same capability and actually cost less than a new tape. It will also be faster, more reliable, and easier to use. Just replace /dev/tape in my examples above with the file you want to (over)write.

To make something happen daily put a script in the /etc/cron.weekly directory. In this case you want the script to look at the day of the week and make the appropriate backup.

I'm not sure of a robust way of having 3 files spread out over a tape and then overwrite one at a time. The mt command allows you to skip to file start markers, so in theory you could create 3 12GB files initially. Use the following command:

dd if=/dev/zero of=/dev/tape bs=1024 count=12000

and then use some combination of mt commands to move around the tape. But I'm not at all sure that such a kludge could be made to work reliably. If you just want to protect against another HD failure then I recommend another drive.

Paul Johnson 03-28-2003 08:41 AM

Almost forgot to mention: each tape device has two names in /dev. In your case it will probably be /dev/st0 and /dev/nst0. The second form stands for "no-rewind".

If you use the first one then the tape will automatically rewind after every operation (so you use mt fsf 3 to skip three files forwards, and then it rewinds again).

Normally the auto-rewind alias is the one that you want. But if you are doing something complicated with multiple files on a tape then you want the no-rewind alias.

Paul.

ravenswood1000 03-30-2003 09:16 AM

Amanda
 
Has anyone had sucess with Amanda for client/server backups?

Paul Johnson 03-30-2003 03:54 PM

> Has anyone had sucess with Amanda for client/server backups?

Yes, me. For the most part it worked very well, although it had an odd failure mode in which the backup happened at a few bytes per second. Never did get to the bottom of that.

There are some other niggles, most of which have to do with the limitations of the underlying programs (e.g. smbtar doesn't do exclusion lists). But overall I'd recommend it.

Paul.

orange400 03-30-2003 05:20 PM

I'm kinda curious about tapes ... are they sensitive to destruction? How fast do they backup?

ravenswood1000 03-30-2003 05:39 PM

I'm currently backing up about 2 gigs on tape a day and it takes about a half an hour to backup and verify. I don't know much about tape longevity though as we just recently started backing things up. I'm hoping that we can rotate tapes once a month.


All times are GMT -5. The time now is 06:51 AM.