borg extract /path/to/repo::$(borg list /path/to/repo --last 1 --format '{archive}') path/to/file1 path/to/file2 make it extract only archives named with a prefix

borg extract archives with prefix from repository path examples

This refinement focuses on extracting archives with a specific prefix from a Borg repository, making it clearer and more targeted for relevant documentation or examples related to Borg and prefix extraction.

To extract files from a Borg repository while ensuring you're targeting only those archives that match a specific prefix, you can modify your command using the borg list options and command substitution to filter archives accordingly. Below, I’ll outline how to structure this command effectively.

Overview of Borg Extraction with Prefix Filtering

BorgBackup allows for efficient extraction of files from compressed and deduplicated archives. By leveraging command substitution alongside pattern matching, you can focus your extractions on archives that start with a particular prefix.

Basic Command Structure

The base command you provided is meant to extract specific files from the most recent archive:

borg extract /path/to/repo::$(borg list /path/to/repo --last 1 --format '{archive}') path/to/file1 path/to/file2

This command retrieves the last archive and extracts file1 and file2 from it. To filter archives by a specific prefix, you can adjust your approach as follows:

Extracting Archives with a Specific Prefix

To extract files only from archives that start with a certain prefix, you can use borg list to filter based on that prefix. Here is the modified command that accomplishes this:

borg extract /path/to/repo::$(borg list /path/to/repo --format '{archive}' | grep '^prefix-') path/to/file1 path/to/file2

Breakdown of the Command

  • borg list /path/to/repo --format '{archive}': This lists all archives in the repository.
  • grep '^prefix-': This filters the list to include only those archives whose names start with prefix-. Replace prefix- with your actual prefix.
  • borg extract /path/to/repo::$(...): This part remains unchanged and continues to extract files from the filtered list of archives.

Complete Example

Let’s say you want to extract files from archives that start with the prefix backup-. Your command would look like this:

borg extract /path/to/repo::$(borg list /path/to/repo --format '{archive}' | grep '^backup-') path/to/file1 path/to/file2

Important Considerations

  1. Multiple Archives Handling: If multiple archives match the prefix, the command will attempt to extract the files from all matching archives, which might create conflicts. Consider specifying whether you want to extract from only the latest of those archives or all.

  2. Extracting All Files: If you want to extract all files from the matched archives rather than specific files, you could remove path/to/file1 path/to/file2 altogether.

  3. Command-Line Environment: Ensure that you have the appropriate permissions and that your command-line environment supports the necessary utilities such as grep.

Additional Resources

For further reading, you can refer to the official Borg documentation on extracting archives which covers various options and configurations.

Conclusion

This efficient command structure allows you to harness the power of BorgBackup for targeted extractions based on archive naming conventions. Adjust the prefix as necessary for your use case to streamline the backup restoration process.

Related Searches

Sources

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

This command extracts the contents of an archive. By default the entire archive is extracted but a subset of files and directories can be selected by passing a ...

2
Usage — Borg - Deduplicating Archiver 1.0.8 documentation
Borgbackup

Examples¶. # Extract entire archive $ borg extract /path/to/repo::my-files # Extract entire archive and list files while processing $ borg extract -v --list / ...

3
Extract without full path · Issue #1102 · borgbackup/borg - GitHub
GitHub

I would like to know if there is a way to extract an archive without getting the full path. I didn't find this answer in the "borg extract ...

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

For example, let's say I have 10 archives in my repository and I wish to apply the retention rule for archive7 then I can use the --prefix flag ...

5
borg — Manpages v3.0.0 - Kaisen Linux
Kaisenlinux

Restore the Monday archive by extracting the files relative to the current directory: $ borg extract /path/to/repo::Monday 7. Delete the Monday archive (please ...

6
Borg Backup: an introduction - Luca Ferrari
Fluca1978

Whithin a repository, borg manages archives, that are the actual backups. I often refer to an archive as a label in the following, because ...

7
borg: BorgBackup is a deduplicating backup program with optional ...
Mankier

Examples. # Extract entire archive $ borg extract /path/to/repo::my-files # Extract entire archive and list files while processing $ borg extract --list /path/ ...

8
borg(1) - Arch Linux manual pages
Man

6. Restore the Monday archive by extracting the files relative to the current directory: $ borg extract /path/to/repo::Monday. 7. Delete the Monday archive ...

9
Get info data on all archives in a repository at once? : r/BorgBackup
Reddit

The borg info command is great for getting the total file size backed up vs the deduplicated size. You can view this info for an individual archive, or for an ...

10
Configuration reference - torsion.org projects
Torsion

Below is a sample borgmatic configuration file including all available options for the most recent version of borgmatic. This file is also available for ...