Info2soft use cookies to help you have a superior and more admissible browsing experience on our website. Privacy Policy
Tape backup remains useful for Linux environments that need offline protection and long-term data retention. Its main advantages include:
tar, mt, and mtx allow administrators to create archives, control tape drives, and automate backup tasks.Despite sequential-access limitations and the need for regular restore testing, tape remains a practical option for offline Linux backups.
Linux provides native command-line utilities such as tar and mt for writing backups to tape drives. Before starting, confirm that the tape device is detected and that the required tools are installed.
Install the necessary packages using your distribution’s package manager:
Ubuntu/Debian:
sudo apt update
sudo apt install mt-st tar mtx
RHEL/Rocky Linux/AlmaLinux:
sudo dnf install mt-st tar mtx
Check whether the tape device is detected:
ls -l /dev/st0
/dev/st0 is the standard non-rewinding tape device on many Linux systems, but it may not exist on every system./dev/nst0 is the corresponding non-rewinding device, commonly used in scripted operations.You can also check the installed tape utilities:
mt --version
tar --version
Before writing a backup, rewind the tape to its beginning:
sudo mt -f /dev/nst0 rewind
Using /dev/nst0 avoids automatic rewinding when the device is closed, giving administrators more control over tape positioning.
Check the tape drive status:
sudo mt -f /dev/nst0 status
Use tar to create an archive and write it directly to the tape:
sudo tar -cvf /dev/nst0 /home
Where:
-c: Creates a new archive.-v: Displays files as they are processed.-f: Specifies the archive destination./home: The directory being backed up.To back up multiple directories:
sudo tar -cvf /dev/nst0 /home /etc /var
The archive is written directly to the tape without creating an intermediate archive file on disk.
A successful tar command does not guarantee that every file can be read back correctly. Verify the archive by listing its contents:
sudo mt -f /dev/nst0 rewind
sudo tar -tvf /dev/nst0
To check whether a specific file is included:
sudo tar -tvf /dev/nst0 | grep "filename"
For stronger verification, perform a test restore to a separate directory and check the restored files.
If the backup exceeds one tape’s capacity, GNU tar supports multi-volume archives through the -M option:
sudo tar -cvMf /dev/nst0 /home
When the current tape is full, tar prompts for another volume. Follow the prompt to replace the tape and continue the backup.
Important: Multi-volume archives require all tapes in the correct sequence during restoration. Label each cartridge clearly and keep the volume order in your backup records.
After the backup finishes, rewind and unload the tape:
sudo mt -f /dev/nst0 rewind
sudo mt -f /dev/nst0 offline
The offline command typically rewinds and unloads the cartridge, depending on the drive.
Label the tape with:
Store the cartridge in a suitable environment and update your tape inventory.
Shell scripts can automate Linux tape backup tasks, reducing manual work and making backup schedules more consistent. The following example demonstrates a basic full and incremental backup workflow.
The script uses tar to create full or incremental archives and writes them to a non-rewinding tape device.
#!/bin/bash
# Set backup variables
TAPE="/dev/nst0"
BACKUP_DIR="/home"
SNAPSHOT="/var/lib/tape-backup.snar"
DATE=$(date +%Y%m%d)
# Rewind tape before starting a full backup
if [ ! -f "$SNAPSHOT" ]; then
sudo mt -f "$TAPE" rewind
fi
# Create full or incremental backup
sudo tar --listed-incremental="$SNAPSHOT" \
-cvf "$TAPE" "$BACKUP_DIR"
# Check backup command status
if [ $? -eq 0 ]; then
echo "Backup completed: $DATE"
else
echo "Backup failed: $DATE" >&2
exit 1
fi
# Rewind and unload tape
sudo mt -f "$TAPE" offline
How it works:
--listed-incremental: Uses a snapshot file to track filesystem changes between backups.SNAPSHOT: Stores incremental backup metadata and should be preserved between runs.DATE: Records the backup date for logging purposes.This is a basic example. A production script should distinguish full and incremental schedules, check tape availability, handle write failures, and preserve snapshot files securely. A full backup should also start with a fresh snapshot.
Use cron to schedule automatic backups. For example, edit the crontab:
sudo crontab -e
Add a daily backup schedule:
0 2 * * * /usr/local/bin/tape-backup.sh
To capture output and email the backup log:
0 2 * * * /usr/local/bin/tape-backup.sh 2>&1 | mail -s "Linux Tape Backup Report" admin@example.com
Replace admin@example.com with the administrator’s email address. The server also needs a configured mail transfer agent (MTA) for email delivery.
Restoring data from tape involves locating the correct archive, positioning the tape, and extracting the required files. You can restore an entire archive or recover individual files using tar.
Restore the entire archive:
Rewind the tape and extract all archived files:
sudo mt -f /dev/nst0 rewind
sudo tar -xvf /dev/nst0 -C /restore/
Restore a specific file:
sha256sum /restore/document.txt
The file path should match the path stored inside the archive. Use tar -tvf /dev/nst0 to check archived filenames before restoring.
The mt utility controls tape positioning and allows administrators to move between archive records or filemarks.
Common commands include:
| Command | Purpose |
|---|---|
mt -f /dev/nst0 rewind |
Rewind tape to the beginning |
mt -f /dev/nst0 fsf 1 |
Skip forward one filemark |
mt -f /dev/nst0 bsf 1 |
Move backward one filemark |
mt -f /dev/nst0 status |
Check tape drive status |
After restoring files, check that the data is accessible and intact:
sha256sum /restore/document.txt
For reliable recovery, periodically perform test restores rather than relying only on successful backup command output.
While native Linux tools such as tar and mt provide command-line control over tape backups, managing backup schedules, monitoring jobs, and maintaining recovery points can become complex as data volumes grow.
i2Backup provides centralized data backup and recovery management, helping IT teams manage backup operations and protect critical business data. It can complement traditional Linux backup workflows by providing a more centralized approach to data protection.
i2Backup supports Linux server backup and tape library storage, providing an alternative to manually managed tar and mt workflows for enterprise environments.
Key capabilities include:
For IT teams managing multiple Linux servers and other enterprise workloads, i2Backup provides centralized backup and recovery management across different environments.
Learn more about Info2soft’s Linux and Unix Backup Solution or visit the Info2soft official website for more information.
Following a few practical guidelines helps improve backup reliability, protect stored data, and reduce recovery risks.
A successful backup command does not guarantee recoverable data. Regularly restore sample files to a separate directory and verify their contents, permissions, and checksums.
The Grandfather-Father-Son (GFS) strategy organizes tapes into daily, weekly, and monthly backup cycles to support different retention periods.
For example:
| Backup Type | Tape Label | Retention |
|---|---|---|
| Daily | Daily-Mon |
1 week |
| Weekly | Weekly-01 |
1 month |
| Monthly | Monthly-2026-10 |
12 months |
Adjust the rotation schedule based on data retention requirements and available tape capacity.
Encrypting backup data helps protect sensitive information if a tape is lost or stolen. You can use GPG to encrypt a tar archive before writing it to tape:
sudo tar -czf - /home | gpg --symmetric --cipher-algo AES256 | sudo dd of=/dev/nst0 bs=1M status=progress
Enter a strong passphrase when prompted and store it separately from the tape. Without the passphrase, you can’t recover the encrypted backup.
Keep a record of each tape’s contents and location to simplify recovery. Useful catalog information includes:
Keep backup tapes in a secure, access-controlled location away from production systems. For offsite storage, use protective cases and follow the tape manufacturer’s recommended temperature and humidity conditions. This helps reduce the risk of physical damage, theft, and site-wide disasters.
Linux tape backup remains a practical option for offline protection, long-term data retention, and large-scale data archiving. Native tools such as tar, mt, and mtx allow administrators to create, manage, and restore tape archives, while shell scripts and cron help automate routine backup tasks.
To maintain reliable backups, test restores regularly, encrypt sensitive data, and follow a consistent tape rotation strategy. For teams managing larger Linux environments, i2Backup also provides centralized backup management and recovery capabilities to simplify enterprise data protection.
· Enterprise & Mid-market Customers Worldwide.
· Support team available to assist you throughout your trial.
· Start a 60-day free trial or view demo to see how Info2soft protects enterprise data.