Bear with me, this is my first post on any kind of Stack Exchange type of website. I’m working on creating a backup server to store the data from my storage server onto multiple tapes in my tape library. I am still learning Linux, so I need help / recommendations on how to continue. I think I have the right idea though. Here’s my setup: Backup Environment

I have the tape library (Quantum SuperLoader 3, LTO-4, SCSI) connected to an old Dell server. I have a combination of LTO-3 and LTO-4 tapes. I have another server I use for storage running FreeNAS. The storage server and the backup server are both connected to a switch on the 10.x network, and they also have a dedicated ethernet cable connecting the two servers together. The NIC’s on the 10.x network are setup as DHCP getting reservations from pfSense, and the NIC’s connecting the two servers together directly are setup static with IP’s of 20.1 and 20.2. I thought this would be a good way of giving the storage server full read access without affecting bandwidth through the switch, and to keep things more secure. On a separate note, could someone set their IP to 20.1 and get access to all of the files on the storage server? I know in FreeNAS you can restrict certain permissions to select IP’s, but I didn’t see anything in there for restricting to a certain ethernet port.

Anyways, I have been able to move tapes around with mtx and transfer data with tar and the multiple tape flag set. When spanning over multiple tapes, it prompts you to eject one tape and put another in. I have to run a second terminal / screen with the mtx commands to switch the tape, then go back to the original and continue the backup. Is there a way I can detect this and automatically switch to a different tape? Would this be best to do in a shell script or something like Python or some other language? Also, in the tar command, you have to specify the size of the tape. Is there a way I can detect what size tape is in the drive to satisfy that? I didn’t see anything in mt, but I might be missing something.

Any help and knowledge and expertise is appreciated. Thanks!

If it helps, here are some of the commands I have been using:

sudo mount -t nfs /home/andrew/FreeNAS/Storage
sudo mt -f /dev/st0 status // Check status of drive
sudo mtx -f /dev/sg3 load 1
sudo tar -v --create --tape-length=800G --file=/dev/st0 
sudo mtx -f /dev/sg3 unload 1
  • 1
    Scheduling and orchestration of tape backups for servers is a fantastic job for Amanda Backup. It's been around forever, and has rich documentation. The community version does what you're looking for. – Spooler Sep 6 '17 at 2:37
  • @SmallLoanOf1M I tried setting up an Amanda server before, but I wasn't as well versed in Linux then as I am now. I think I'll revisit it though. – Andrew K. Sep 7 '17 at 0:23
  • 1
    You were asking for a script, and this page: Linux Tape Backup With mt And tar Command Howto has a nice script, confirmed to work even now. – gsl Sep 15 '17 at 16:50
  • @gsl I actually looked at that previously to get some of the commands I have above. That script doesn't do multi-tape backups, unless they have a second script somewhere that I'm missing. It doesn't look like it ever reads the total size of the tape either so it knows how much to write to one tape before having to switch to another. I see there is the M flag for multiple tapes. I also see there is a ! flag to run in a sub-shell. Maybe I would want to use ! and then pipe it into something so I can detect when it says "Swap tape and press Y" so I can run a command to switch, then continue? – Andrew K. Sep 15 '17 at 22:07
  • Actually, I just re-read the tar page. ! is actually a response that tar would accept when it reaches the end of a tape. I'm searching to see what it does. Maybe it could run a command after a tape. – Andrew K. Sep 15 '17 at 22:09

You already have all the tools in place, you're just missing the glue:

never needet it myself, but my tar manual says, that you can execute a script at end of each tape using --new-volume-script your_script.

your_script just should make sure the new tape is in place before exiting.


All yours needs can find theirs answers with bacula

With that, you will be able to :

  • choose the destinations of yours saves,
  • manage yours tapes
  • configure rotation of yours tapes depending of your backup strategy (full, incremnetial or differential, etc...)
  • define you retention strategy of yours tapes.
  • etc...

It works in Client/Server mode and you can split the differents functions of bacula between severals servers.

You can manage yours backup as you wish

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.