Go to file
2024-11-01 10:49:44 +01:00
docs (feature): init 2024-10-31 14:06:32 -07:00
src (refactor): get rid of most thread sleep 2024-11-01 10:49:44 +01:00
.gitattributes (feature): init 2024-10-31 14:06:32 -07:00
.gitignore (feature): init 2024-10-31 14:06:32 -07:00
CONTRIBUTING.md (feature): init 2024-10-31 14:06:32 -07:00
LICENSE.md (feature): init 2024-10-31 14:06:32 -07:00
README.md (feature): init 2024-10-31 14:06:32 -07:00

MaksIT.LTO.Backup

A C# application designed to facilitate backup and restore operations to an LTO tape drive. This application enables seamless management of backups by handling file organization, descriptor creation, and efficient tape handling processes for loading, writing, and restoring data.

Features

  • Load and Eject Tape: Safely loads and unloads the tape using TapeDeviceHandler.
  • Backup Operation: Allows users to create a descriptor file for organizing file metadata and backs up files to the LTO tape in structured blocks.
  • Restore Operation: Reads data from the tape and restores files to a specified directory, reconstructing original file structure.
  • Customizable Block Sizes: Supports multiple LTO generations, allowing customization of block sizes based on the tape generation (e.g., LTO-6).
  • File Descriptor Management: Metadata is organized for each file, including file paths, sizes, creation, and modification times.
  • Zero-Filled End Blocks: Marks the end of a backup with zero-filled blocks to assist with reading and integrity checks.

Requirements

  • .NET8 or higher
  • JSON configuration files: configuration.json and descriptor.json (auto-generated)
  • LTO Tape Drive and compatible drivers

Setup

  1. Clone the repository:
    git clone https://github.com/your-username/MaksIT.LTO.Backup.git
    
  2. Ensure .NET Core is installed on your system.
  3. Prepare a configuration.json file in the application directory with the following structure:
    {
      "TapePath": "YourTapePath",
      "Backups": [
        {
          "Name": "BackupName",
          "Barcode": "123456",
          "Source": "path/to/source",
          "Destination": "path/to/destination",
          "LTOGen": "LTO6"
        }
      ]
    }
    

Usage

Running the Application

Execute the application by navigating to the project directory and running:

dotnet run

Application Menu

Upon running, the following options will be presented:

  1. Load Tape: Loads the tape into the drive.
  2. Backup: Prompts the user to select a backup task from the configured list and initiates the backup process.
  3. Restore: Restores a previously backed-up directory from the tape.
  4. Eject Tape: Ejects the tape from the drive safely.
  5. Exit: Exits the application.

Code Overview

  • Application Class: Main class handling backup and restore functionalities. Provides methods like LoadTape, EjectTape, Backup, Restore, CreateDescriptor, WriteFilesToTape, and FindDescriptor.
  • TapeDeviceHandler: Controls tape device operations such as setting positions, writing data, and reading data.
  • BackupDescriptor: Organizes metadata for backed-up files. Used to log details about each file block on tape.

Sample Configuration

Below is an example configuration setup for an LTO-6 tape generation backup operation:

{
  "TapePath": "\\\\.\\Tape0",
  "Backups": [
    {
      "Name": "Monthly Backup",
      "Barcode": "MB12345",
      "Source": "/path/to/source",
      "Destination": "/path/to/restore",
      "LTOGen": "LTO6"
    }
  ]
}

Error Handling

Errors during backup or restore are caught and logged to the console. Ensure that your TapeDeviceHandler is correctly configured and that the tape drive is accessible.

License

This project is licensed under the terms of the GPLv2. See the LICENSE file for full details.

© Maksym Sadovnychyy (MAKS-IT) 2024