Backup to LTO with Amanda on TrueNAS Core

Aluveitie

Cadet
Joined
Nov 11, 2022
Messages
2
I recently got my hands on an LTO tape drive. Finding useful information was quite tricky and it took a lot of trial and error to find a starting point.
Since useful information is very scattered, I've collected things together in a little guide, maybe it's helpful for someone:

Creating jail​

First we need to create a jail with access to the tape drive.
Create a jail using the "Advanced Jail Creation". Under Jail Properties set `devfs_ruleset` to `0`, enable `allow_mount` and select `allow_mount_devfs` under the `allow_mount_*` dropdown.
Then create and start the jail.

As root on TrueNAS enter the jail using `iocage console <your jail name>`.
Check you can access the tape drive from your jail using `mt status`.
The output should look like this:
Code:
Drive: sa0: <TANDBERG LTO-6 HH 3329>
---------------------------------
Mode      Density              Blocksize      bpi      Compression
Current:  0x5a:LTO-6           variable       384607   enabled (0x1)
---------------------------------
Current Driver State: at rest.
---------------------------------
Partition:   0      Calc File Number:   0     Calc Record Number: 0
Residual:    0  Reported File Number:   0 Reported Record Number: 0
Flags: BOP


# Basic setup
Then type `pkg info` to install the package manager.<br/>
Then install the necessary software:
Code:
pkg install amanda-server amanda-client aespipe


Enable inetd to run the Amanda service later
Code:
echo 'inetd_enable="YES"' >> /etc/rc.conf

Then restart the jail to apply those changes and log back in.

Create and empty `/etc/fstab` as Amanda requires the file to be there, also the hosts configuration file.
Code:
touch /etc/fstab


pkg already created an `amanda` user/group. To later use it we need to assign a login shell:
Code:
chsh -s /bin/csh amanda



Prepare config and var directories:
Code:
chown amanda:amanda /usr/local/etc/amanda
mkdir -p /var/lib/amanda
chown amanda:amanda /var/lib/amanda


Configure Amanda Server​

First configure the Amanda server by appending in `/etc/inted.conf`:
Code:
amanda stream tcp nowait amanda /usr/local/libexec/amanda/amandad amandad -auth=bsdtcp amdump amindexd amidxtaped

and restart inetd:
Code:
service inetd restart


If you don't find a predefined `tapetype` for your drive you need to run `amtapetype` to test the speed, size etc of the tape.
This can run for a couple of hours. You may need to give it size hint for it to complete in reasonable time, see amtapetype(8).
Code:
amtapetype -f /dev/sa0

This should give out the `tapetype` definition of our tape drive looking like:
Code:
define tapetype tandberg-lto6hh {
    comment "Tandberg LTO-6 HH; compression enabled"
    length 2442932512 kbytes
    filemark 1065 kbytes
    speed 137420 kps
    blocksize 32 kbytes
}


Then let amanda create our backup configuration, see amserverconfig(8).
Code:
su - amanda
amserverconfig sample-backup --template single-tape --tapedev /dev/sa0 --mailto admin@example.local

Edit the generated `/usr/local/etc/amanda/sample-backup/amanda.conf` and add the `define tapetype` block from above and adapt the `tapetype` to it.

Next copy the `/usr/local/share/amanda/example/amanda-client.conf` to `/usr/local/etc/amanda` and adapt it:
Code:
conf "sample-backup"            # your config name

index_server "localhost"        # your amindexd server
tape_server  "localhost"        # your amidxtaped server
tapedev      "tape:/dev/sa0"    # your tape device
auth "bsdtcp"

ssh_keys ""                     # your ssh keys file if you use ssh auth

`amrecover` will use this to initialize.

Prepare localhost access by creating the file `/var/db/amanda/.amandahosts` to allow connections from localhost:
Code:
localhost amanda amdump
localhost root amindexd amidxtaped


Then fix permissions of etc folder as root again (Amanda client requires /usr/local/etc/amanda to belong to root)
as well as the `.amandahosts` file which must belong to `amanda` user and be accessible by the user only.
Code:
chown root:wheel /usr/local/etc/amanda
touch /var/db/amanda/.amandahosts
chmod 600 /var/db/amanda/.amandahosts
chown amanda:amanda /var/db/amanda/.amandahosts



Testing backup​

With our completed configuration we can go on and test our setup and do a simple backup/restore.

Run the integrated check as amanda user:
Code:
amcheck sample-backup

There should be no errors besides mentioning tape labels.

Next we set up the disk list to quickly back something up in `/usr/local/etc/amanda/sample-backup/disklist`:
Code:
localhost /etc root-tar

If the tape drive is using hardware compression, root-tar should be a good fit. See `/usr/local/etc/amanda/template.d/dumptypes` and disklist(5).

We need to label a tape for Amanda to backup to it, matching our `labelstr` defined in the `amanda.conf`:
Code:
amlabel -f sample-backup sample-backup-0


Then write our first backup:
Code:
amdump sample-backup


To test recover, we need to run `amrecover` as `root`:
Code:
mkdir /tmp/test
cd /tmp/test
amrecover sample-backup
amrecover> sethost localhost
amrecover> setdisk /etc
amrecover> ls
amrecover> add resolv.conf
amrecover> extract

`amrecover` will note which tape to insert and continue to extract the selected file into `/tmp/test` . You can quit `amrecover` with `exit`.

To clean up our test run, delete the tape as `amanda` user again:
Code:
amrmtape sample-backup sample-backup-0
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Fancy. Late last year, I had to wrestle with an old tape library (which seems to have one dying PSU and one dead PSU) with two old tape drives, both seized up - but I did get one of the drives to work, though not inside the library.

I have to admit, I was intrigued by the whole thing, but the economics just aren't there in my case.
 

Aluveitie

Cadet
Joined
Nov 11, 2022
Messages
2
Still playing around and trying to figure out if this can be a suitable backup solution :)
 
Joined
Jun 15, 2022
Messages
674
Still playing around and trying to figure out if this can be a suitable backup solution :)
It can be for several solid reasons the tape zealot will espouse. I love tape, though it's slothy s-l-o-w.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
I was so happy with tape speed on LTO3 when I saw that the tape had reached its end. Then the drive started reading in reverse. Then I looked up the number of tracks on the tape and the realization of my (then) near future sunk in.
 

acp

Explorer
Joined
Mar 25, 2013
Messages
71
It can be for several solid reasons the tape zealot will espouse. I love tape, though it's slothy s-l-o-w.
While I use bacula I find tape quite the solution. I started with an lto 5 drive. Then I went all in with an library (TL4000). I too have found documentation is lacking or just plan wrong. I just kept at it. I can fill a lto 5 tape (1.5 tb) in about 6 hours. My solution is fully virtualized. Now I'm all automated. Next is to figure out tape encryption.
 

Attachments

  • Screenshot_20230620-231251~2.png
    Screenshot_20230620-231251~2.png
    373.3 KB · Views: 170
Top