FreeBSD and Tape LTO-9

Hello,

I'm trying to implement backups on a FreeBSD system of the data it stores (user files, databases, etc.) using an LTO-9 magnetic tape drive...

From what I've seen, there are two ways to use this drive: the traditional way with the mt and tar utilities, or the newer LTFS (the tape functions like a hard drive).

Testing environment:

# mkdir /tmp/test1

# echo 'Hello World!' > /tmp/test1/file1.txt
# echo 'Hello World!' > /tmp/test1/file2.txt
# echo 'Hello World!' > /tmp/test1/file3.txt

# mkdir /tmp/test2

# echo 'Hello World!' > /tmp/test2/file1.txt
# echo 'Hello World!' > /tmp/test2/file2.txt
# echo 'Hello World!' > /tmp/test2/file3.txt


A. Example whit the utilities mt and tar

mt – magnetic tape manipulating program
tar – manipulate tape archives

Load the auto rewind tape on FreeBSD: /dev/sa0

# mt -f /dev/sa0 load


Erase the tape

# mt -f /dev/sa0 erase


View the status

# mt -f /dev/sa0 status


Make a backup

# tar -czf /dev/sa0 /tmp/test1 /tmp/test2


View backup

# tar -tzf /dev/sa0

Code:
tmp/test1/
tmp/test1/file1.txt
tmp/test1/file2.txt
tmp/test1/file3.txt
tmp/test2/
tmp/test2/file1.txt
tmp/test2/file2.txt
tmp/test2/file3.txt

Restore the backup

# mkdir /tmp/restore
# cd /tmp/restore
# tar -xzf /dev/sa0 tmp/test1 tmp/test2


View the restore backup

# find /tmp/restore | sort -n

Code:
/tmp/restore
/tmp/restore/tmp
/tmp/restore/tmp/test1
/tmp/restore/tmp/test1/file1.txt
/tmp/restore/tmp/test1/file2.txt
/tmp/restore/tmp/test1/file3.txt
/tmp/restore/tmp/test2
/tmp/restore/tmp/test2/file1.txt
/tmp/restore/tmp/test2/file2.txt
/tmp/restore/tmp/test2/file3.txt

Eject the tape

# mt -f /dev/sa0 offline



B. Example with LTFS (Linear Tape File System)

Required only the first time (install module, load module, start with system, insert tape, create file system, eject tape)

# pkg install -y ltfs
# kldload fusefs

# echo '# LTFS (Linear Tape File System)' >> /etc/rc.conf
# sysrc kld_list+=fusefs

# mt -f /dev/sa0 load

# mkltfs -d /dev/sa0 -f

# mt -f /dev/sa0 offline


To use the tape (create the mounting point and mount the tape)

# mkdir /mnt/ltfs

# ltfs -o devname=/dev/sa0 /mnt/ltfs


View tape mounted

# df -h | grep -E 'Filesystem|ltfs'

Code:
Filesystem                                   Size    Used   Avail Capacity  Mounted on
ltfs:/dev/sa0                                 16T     10M     16T     0%    /mnt/ltfs

Example of a backup using the rsync utility

# rsync -av --delete /tmp/test1 /mnt/ltfs
# rsync -av --delete /tmp/test2 /mnt/ltfs


To view the backup

# ls /mnt/ltfs

Code:
test1    test2

To umount the tape and eject

# umount /mnt/ltfs

# mt -f /dev/sa0 offline



After my somewhat lengthy introduction (apologies for that), I have a few questions:

In your experience, which do you think is better? Way A or way B?

In mode A, how do you perform subsequent backups without overwriting the previously made backup?

I've detected some issues in Mode B (LTFS and RSYNC). The tape seems to have problems with large file sizes or deep folders, which is why RSYNC reports that it couldn't assign attributes to some files. As a result, when RSYNC is run again, it repeatedly deletes and rewrites the same files.


Thank you for your time and recommendations!
 
In mode A, how do you perform subsequent backups without overwriting the previously made backup?
You have to keep the history of your backups and save any subsequent job after the last one using the "fast forward" switch of the mt command. "Real" backup software will do this for you but I'm sure you'll find shell scripts on the web that will suit you.
 
This article [PDF] from the FreeBSD Journal is a few years old, but it lays out the options for talking to tape drives on FreeBSD pretty nicely.

As to your original question, based on your problem description (backing up user files and databases), I think you would be better off with one of the ”proper” backup software packages (like Amanda or Bacula/BareOS, or even a commercial alternative such as Archiware P5).

If you’re doing this as a hobby, creating homegrown scripts can be a useful learning exercise, but if this is for work, they can be a recipe for disaster instead of disaster recovery if you don’t know exactly what you’re doing.
 
In your experience, which do you think is better? Way A or way B?
In general I prefer gtar (GNU tar) over LTFS for tape archives because from my point of view LTFS serves the purpose of allowing you to use a tape like a hard drive, and in my experience there are only edge cases where I would like to use a tape as a hard drive (think external USB hard drive) instead of an actual hard drive. LTFS is the idea of having the cake and eating it at the same time.

In mode A, how do you perform subsequent backups without overwriting the previously made backup?

I don't. These days, I use LTO7 for all of my archives. Although some of my data exceeds LTO7's capacity, I will have to use LTO8. I always put a single archive on a single tape; I never add any data at a later point in time. Cartridges are too cheap compared of the value of the data in terms of potential data loss. So if one LTO7 doesn't fit the bill, I separate my data according to my available tape drives for archive, at the moment LTO7 and LTO8.

I've detected some issues in Mode B (LTFS and RSYNC). The tape seems to have problems with large file sizes or deep folders, which is why RSYNC reports that it couldn't assign attributes to some files. As a result, when RSYNC is run again, it repeatedly deletes and rewrites the same files.
I don't share that experience, although I have been using LTFS on Linux on request most of the time. Like I already mentioned above think of LTFS like an external USB hard drive, I can't recommend LTFS for archival/backup purpose and long term storage.

Perhaps a few notes on LTO9. I am not going to upgrade to LTO9, in fact I will skip LTO9 and wait for LTO10, as the environmental data is written to the cartridge as well which makes it very interesting to restore that data, if the environment somehow changes. As far as I know, there have been several reports about tapes which couldn't be restored because of that environmental sensor feature and in conclusion the vendors are going to drop support for that feature in LTO10.

I know there is some resentment in IT regarding tape technology and it is seen as old-fashioned.

I have found tape to be a very reliable long term storage media (at least >= 10 years) as long as I keep it simple, stupid.
 
Back
Top