borg list. how to format with newlines

Borg list formatting with newlines tutorial 2025

Specified 'tutorial' to indicate a guide is being sought and included the current year to get the most recent and relevant results on formatting Borg lists.

When working with BorgBackup, formatting the output of the borg list command is essential for readability, especially if you're looking to separate items with newlines. Below is a thorough guide on how to achieve this, along with key insights into the borg list command's functionality.

Understanding the borg list Command

The borg list command is utilized for listing the contents of a repository or an archive in BorgBackup. It provides a structured way to visualize files, directories, and archives you've backed up. To enhance the output's clarity, especially when dealing with large repositories, formatting can be adjusted using several command-line options.

Formatting Output with Newlines

To format the output of borg list with newlines specifically, you will leverage the --format option, which defines how each item is displayed. Here’s how to do it:

Basic Command Structure

borg list [REPOSITORY] --format '{id} {file_name}\n'

Example Usage

  1. List all items with newlines:

    If you want to list the contents of a Borg repository and ensure each item appears on a new line, you could execute:

    borg list /path/to/repo --format '{path}\n'
    

    In this command:

    • Replace /path/to/repo with your actual repository path.
    • {path} refers to the full path of each file or directory listed.
    • The \n at the end adds a newline after each listed item.
  2. Custom Formats:

    You can customize the format further if you want to include other metadata—like the size or modification time—while still ensuring each piece of information appears clearly on a new line. For example:

    borg list /path/to/repo --format '{time:%y-%m-%d %H:%M:%S} {size} {path}\n'
    

    This will produce output formatted like:

    2025-10-02 14:30:12 200KB /file1.txt
    2025-10-02 14:31:23 300KB /file2.txt
    

Using JSON or JSON Lines

If you prefer machine-readable formats, BorgBackup supports outputting in JSON format. While the --json-lines option doesn't allow for direct newline formatting in the same way, it still provides clear formatting for processing in scripts.

borg list /path/to/repo --json-lines

This command outputs each item as a JSON object on a separate line, suitable for parsing by other tools, albeit without the customizable formatting options of the --format flag.

Additional Tips

  • For extended help on borg list and its formatting options, you can refer to the Borg Backup documentation here.
  • Experiment with different placeholders in the --format option to cater to your specific output requirements. The available placeholders include {path}, {size}, {mtime}, and others.

Conclusion

Formatting the output of the borg list command with newlines is a straightforward process using the --format option. This allows you to tailor the information for better readability, making it easier to analyze or share with others. For complex needs or automation, consider leveraging JSON formats. BorgBackup’s flexibility makes it a robust tool for backup management, accommodating various styles of output suited to your workflow.

People Also Ask

Related Searches

Sources

10
1
borg list — Borg - Deduplicating Archiver 1.4.1 documentation
Borgbackup

This command lists the contents of a repository or an archive. For more help on include/exclude patterns, see the borg help patterns command output.

2
borg create — Borg - Deduplicating Archiver 1.4.1 documentation
Borgbackup

This command creates a backup archive containing all files found while recursively traversing all paths specified.

3
Tutorial: Using Borg for backup your QNAP to other devices (Advanced
Reddit

This tutorial will explain how to use Borg Backup to perform backups. This tutorial will specifically be aimed to perform backups from our QNAP to another unit.

4
Wildcard extraction does not work · Issue #8589 · borgbackup/borg
GitHub

I tried to extract multiple files that have the same prefix. The simplest method to achieve this in my mind would be to use a wildcard.

5
borg-patterns(1) — borgbackup — Debian testing
Manpages

A more general and easier to use way to define filename matching patterns exists with the --pattern and --patterns-from options.

6
Unlock Ultimate Backup Security: Borg Backups & Borgmatic Guide
YouTube

Dive into the world of secure, efficient, and fully open-source backup solutions with our comprehensive guide on Borg Backups and Borgmatic!

7
Backup And Restore Files Using Borg In Linux - OSTechNix
Ostechnix

This tutorial explains what is BorgBackup and how to backup and restore files using Borg in Linux and Unix-like systems.

8
borg-list(1) - Arch manual pages
Man

Only valid for listing repository contents. Format output as JSON. The form of --format is ignored, but keys used in it are added to the JSON output. Some keys ...

9
borg-list - List archive or repository contents - Ubuntu Manpage
Manpages

--json-lines Only valid for listing archive contents. Format output as JSON Lines. The form of --format is ignored, but keys used in it are added to the ...

10
Install and Configure BorgBackup | Hetzner Community
Community

Step 2.1 - Activate Borg and configure your Storage Box · Step 2.2 - Initialize Borg repository · Step 2.3 - Create first backup · Step 2.4 - ...