Enscand, Inc.


Remote Tape Backups on Linux


Of course, with all howtos, I assume no responsibility for anything bad that happens if you follow the advice contained in these documents. I'm merely trying to be helpful, by conveying what worked for me. By implementing my advice, you are implicitly accepting this disclaimer. Comments are appreciated, though.


So, if you're a small business type like me, or simply have no money, or time,
to buy and install tape drives in all your machines (and remember to change the
tapes in all those drives at the right intervals), you may want to consider using
the tape drive on one central machine to archive all your Un*x boxes.  It's not
too difficult, but was hard enough that I thought it would be worth writing
down.

Prerequisites


1) One pre-installed, working Linux tape device
2) A reasonably fast network.  remember all that data has got to go across the
local net to get to the remote tape device.  I have either 100BaseT, or Gigabit
cards, and switches in my network.
3) A basic understanding of how to use tape drives, and cron jobs.

My Configuration


Linux OS: SuSE Linux 8.1 (2.4.21-151 kernel)
collette:/home/nscan # uname
Linux
collette:/home/nscan # uname -r
2.4.21-151-default
collette:/home/nscan/doc/notes/current/old # rpm --query openssh
openssh-3.4p1-215
collette:/home/nscan/doc/notes/current/old # rpm --query tar
tar-1.13.25-45

My Solution (or the one I found by Googling around ;)


The basic technique that I use is to run tar on the machine to be backed up.  I create
a tar achive and pipe it into an ssh command which securely logs in to the machine
with a tape drive, then takes the (tar) input and sends it to the dd command, which
does a raw write of the data to the tape device.  Restoring is done in the reverse
direction.

Not My Solution


First, I pursued the rmt command, which it took me a while to locate and install on my
system.  It turned out to be a major pain in the rear, and as far as I know, doesn't
encrypt any data you're transferring over the network.  Since I'm paranoid about snoops,
among other things, the solution I found was all around better, and didn't require finding
any rmt, or star RPMs.

The Commands


To backup:

cd /folder/to/be/backed/up
tar cpvf - . | ssh user@host_with_tape_drive "/bin/dd of=/dev/st0"

then, depending on your ssh setup, you may get prompted for the password.  If you're
trying to incorporate this into an automatic cron job, then you need to setup ssh
pulic key authentication to allow the ssh client side to automatically pass a pre-approved
public key to the server (tape side) to gain access without prompts.

You also will need to adjust the command line if dd isn't in /bin on your system, or
if your tape isn't named /dev/st0 like mine.

To restore:

cd /temp/folder/to/hold/backup/data
ssh user@host_with_tape_drive "/bin/dd if=/dev/st0" | tar xvpf -

Keep in mind that depending on the responsiveness of your ssh service, it may appear that files are being backed-up or restored before the ssh authentication has taken place. So, wait a bit to make sure you're not going to be prompted for your password. Otherwise, you may leave for a few hours, and return to find out that nothing has really happened .. the system is waiting for your input :(

That's it!  Enjoy the relative simplicity of having only one tape drive.



Copyright © 2003-2024 Enscand, Inc.
All Rights Reserved