Fix: Rustic-nas.service Failed On Storage

by Alex Johnson 42 views

Experiencing issues with your rustic-nas.service? This comprehensive guide will walk you through the process of diagnosing and resolving the "No repository config file found" error. We'll break down the problem, analyze the logs, and provide step-by-step solutions to get your NAS backups running smoothly again.

Understanding the rustic-nas.service Failure

When dealing with service failures, it's essential to understand the root cause. In this case, the rustic-nas.service on the storage host failed, as indicated by the error message: "No repository config file found for local:/mnt/storage/backups/rustic." This error suggests that the Rustic backup service cannot locate the necessary configuration file within the specified repository path.

The failure occurred on November 30, 2025, at 02:53:32 EST, with an exit code of 1, signaling a general failure. The service had been running for a short period before failing, consuming minimal CPU time (31ms) and memory (23.2M). This points to a configuration issue rather than a resource exhaustion problem.

Analyzing the Service Status

The service status output provides valuable clues about the failure:

× rustic-nas.service - Rustic backup service for nas
     Loaded: loaded (/etc/systemd/system/rustic-nas.service; linked; preset: ignored)
     Active: failed (Result: exit-code) since Sun 2025-11-30 02:53:32 EST; 1min 0s ago
 Invocation: 35433d312dec4811be73c8c3efd16fc5
TriggeredBy: ● rustic-nas.timer
    Process: 2096148 ExecStart=/nix/store/l60dx21f90j4f19xx40gcwaql67xp4xh-rustic-0.10.2/bin/rustic -P nas backup (code=exited, status=1/FAILURE)
   Main PID: 2096148 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
         IO: 11.2M read, 0B written
   Mem peak: 23.2M
        CPU: 31ms

Nov 30 02:53:32 storage rustic[2096148]: Message:
Nov 30 02:53:32 storage rustic[2096148]: No repository config file found for `local:/mnt/storage/backups/rustic`. Please check the repository.
Nov 30 02:53:32 storage rustic[2096148]: Some additional details ...
Nov 30 02:53:32 storage rustic[2096148]: Backtrace:
Nov 30 02:53:32 storage rustic[2096148]: disabled backtrace (set 'RUST_BACKTRACE="1"' environment variable to enable)
Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Main process exited, code=exited, status=1/FAILURE
Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Failed with result 'exit-code'.
Nov 30 02:53:32 storage systemd[1]: Failed to start Rustic backup service for nas.
Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Consumed 31ms CPU time, 23.2M memory peak, 11.2M read from disk.
Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Triggering OnFailure= dependencies.

Key observations:

  • The service is in a failed state with Result: exit-code. This confirms the failure and the need for troubleshooting.
  • The ExecStart line shows the command that was executed: /nix/store/l60dx21f90j4f19xx40gcwaql67xp4xh-rustic-0.10.2/bin/rustic -P nas backup. This indicates that the rustic binary was invoked with the backup command, targeting the nas profile.
  • The error message "No repository config file found for local:/mnt/storage/backups/rustic" is the core issue we need to address. This means that Rustic cannot find its configuration files in the specified backup directory.

Examining Recent Logs

Recent logs provide a chronological view of events leading up to the failure:

Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Triggering OnFailure= dependencies.
Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Consumed 31ms CPU time, 23.2M memory peak, 11.2M read from disk.
Nov 30 02:53:32 storage systemd[1]: Failed to start Rustic backup service for nas.
Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Failed with result 'exit-code'.
Nov 30 02:53:32 storage systemd[1]: rustic-nas.service: Main process exited, code=exited, status=1/FAILURE
Nov 30 02:53:32 storage rustic[2096148]: disabled backtrace (set 'RUST_BACKTRACE="1"' environment variable to enable)
Nov 30 02:53:32 storage rustic[2096148]: Backtrace:
Nov 30 02:53:32 storage rustic[2096148]: Some additional details ...
Nov 30 02:53:32 storage rustic[2096148]: No repository config file found for `local:/mnt/storage/backups/rustic`. Please check the repository.
Nov 30 02:53:32 storage rustic[2096148]: Message:
Nov 30 02:53:32 storage rustic[2096148]: error: `rustic_core` experienced an error related to `the configuration`.
Nov 30 02:53:32 storage systemd[1]: Starting Rustic backup service for nas...
Nov 29 01:29:44 storage systemd[1]: rustic-nas.service: Triggering OnFailure= dependencies.
Nov 29 01:29:44 storage systemd[1]: rustic-nas.service: Consumed 16ms CPU time, 22.5M memory peak, 10.8M read from disk.
Nov 29 01:29:44 storage systemd[1]: Failed to start Rustic backup service for nas.
Nov 29 01:29:44 storage systemd[1]: rustic-nas.service: Failed with result 'exit-code'.
Nov 29 01:29:44 storage systemd[1]: rustic-nas.service: Main process exited, code=exited, status=1/FAILURE
Nov 29 01:29:44 storage rustic[210509]: disabled backtrace (set 'RUST_BACKTRACE="1"' environment variable to enable)
Nov 29 01:29:44 storage rustic[210509]: Backtrace:
Nov 29 01:29:44 storage rustic[210509]: Some additional details ...
Nov 29 01:29:44 storage rustic[210509]: No repository config file found for `local:/mnt/storage/backups/rustic`. Please check the repository.
Nov 29 01:29:44 storage rustic[210509]: Message:
Nov 29 01:29:44 storage rustic[210509]: error: `rustic_core` experienced an error related to `the configuration`.
Nov 29 01:29:44 storage systemd[1]: Starting Rustic backup service for nas...

The logs confirm the repeated failure due to the missing configuration file. The error message "error: rustic_core experienced an error related to the configuration" further reinforces this diagnosis.

Troubleshooting Steps

Now that we have a clear understanding of the issue, let's proceed with the troubleshooting steps.

1. Verify Repository Path

The first step is to ensure that the repository path specified in the rustic-nas.service configuration is correct. The error message indicates that the path is local:/mnt/storage/backups/rustic. Let's verify this path:

  • Check the filesystem: Use the ls command to check if the directory /mnt/storage/backups/rustic exists.

    ls -l /mnt/storage/backups/rustic
    

    If the directory does not exist, you'll need to create it:

    sudo mkdir -p /mnt/storage/backups/rustic
    sudo chown -R $USER:$USER /mnt/storage/backups/rustic
    

    Replace $USER with the appropriate user that Rustic runs under. This ensures that the service has the necessary permissions to access the directory.

2. Check for the Configuration File

Next, we need to verify that the Rustic configuration file exists within the repository directory. By default, Rustic stores its configuration in a subdirectory named .rustic inside the repository.

  • List the contents of the repository:

    ls -l /mnt/storage/backups/rustic/.rustic
    

    You should see files like config (the main configuration file) and potentially other files related to indexes and snapshots. If the .rustic directory or the config file is missing, this is the primary cause of the error.

3. Initialize the Repository (If Necessary)

If the repository hasn't been initialized, or if the configuration files are missing, you'll need to initialize the repository using the rustic init command.

  • Initialize the repository:

    rustic init -r local:/mnt/storage/backups/rustic
    

    This command creates the necessary configuration files and directory structure within the repository. You may also need to set a password for your repository:

    export RUSTIC_PASSWORD=your_strong_password
    rustic init -r local:/mnt/storage/backups/rustic
    unset RUSTIC_PASSWORD
    

    Important: Replace your_strong_password with a strong and secure password. It's recommended to use a password manager to generate and store your passwords.

4. Review rustic-nas.service Configuration

Double-check the rustic-nas.service file to ensure that the repository path and other settings are correctly configured.

  • View the service file:

    sudo cat /etc/systemd/system/rustic-nas.service
    

    Pay close attention to the ExecStart line, which specifies the command that Rustic executes. Ensure that the -r option (or -P for profile) points to the correct repository location.

    Example ExecStart line:

    ExecStart=/nix/store/l60dx21f90j4f19xx40gcwaql67xp4xh-rustic-0.10.2/bin/rustic -P nas backup
    

    If you make any changes to the service file, you'll need to reload the systemd configuration:

    sudo systemctl daemon-reload
    

5. Set Environment Variables (If Required)

In some cases, Rustic may require specific environment variables to be set. Check the Rustic documentation or the service file for any required environment variables, such as RUSTIC_PASSWORD or RUSTIC_REPOSITORY.

  • Set environment variables in the service file:

    You can set environment variables directly within the rustic-nas.service file using the Environment= directive.

    [Service]
    Environment=RUSTIC_PASSWORD=your_password
    Environment=RUSTIC_REPOSITORY=local:/mnt/storage/backups/rustic
    

    Remember to reload the systemd configuration after making changes.

6. Test the Backup Command

Before restarting the service, it's a good idea to test the backup command manually to ensure that it works as expected.

  • Run the backup command manually:

    sudo /nix/store/l60dx21f90j4f19xx40gcwaql67xp4xh-rustic-0.10.2/bin/rustic -P nas backup
    

    If the command executes without errors, it indicates that the configuration is correct, and the service should start successfully.

7. Restart the rustic-nas.service

After verifying the configuration and testing the backup command, restart the rustic-nas.service:

  • Restart the service:

    sudo systemctl restart rustic-nas.service
    
  • Check the service status:

    sudo systemctl status rustic-nas.service
    

    If the service starts successfully, the status should show active (running). If the service fails to start, review the logs again for any new error messages.

Common Pitfalls and Solutions

  • Incorrect Repository Path: Double-check the repository path in the service file and ensure it matches the actual directory on your system.
  • Missing Configuration Files: If the .rustic directory or the config file is missing, initialize the repository using rustic init.
  • Permissions Issues: Ensure that the user running the Rustic service has the necessary permissions to read and write to the repository directory.
  • Incorrect Environment Variables: Verify that all required environment variables are set correctly in the service file or system-wide.
  • Password Issues: If you're using a password-protected repository, ensure that the RUSTIC_PASSWORD environment variable is set correctly.

Conclusion

Troubleshooting service failures can be challenging, but by systematically analyzing the logs, verifying the configuration, and testing the commands, you can identify and resolve the root cause. In this case, the rustic-nas.service failure was due to a missing repository configuration file. By following the steps outlined in this guide, you should be able to get your Rustic backups running smoothly again.

Remember to regularly monitor your backup services and check the logs for any errors. Proactive monitoring can help you identify and address issues before they lead to data loss.

For more information on Rustic, you can visit the official Rustic documentation.