borg create --progress /path/to/your/repository::archive-name-$(date +%Y-%m-%d_%H-%M-%S) /path/to/files/to/backup borg prune --prefix 'archive-name-' --keep-last 3 /path/to/your/repository > command to extract the last archive that was created with this command

borg backup extract last archive command 2025

This refinement focuses on extracting the last created archive using Borg, includes the term 'backup' for clarity, and adds the current year for relevance in search results.

To extract the most recently created archive using Borg, you can utilize the borg extract command along with the --last option. This option simplifies the process by directly targeting the latest archive in your backup repository. Below is a detailed explanation, including the command structure and relevant background information.

Extracting the Last Archive with Borg

1. Understanding the Commands

First, let's break down the commands you've provided for context:

  • Creating an Archive:

    borg create --progress /path/to/your/repository::archive-name-$(date +%Y-%m-%d_%H-%M-%S) /path/to/files/to/backup
    

    This command creates a backup archive with a timestamp in its name, indicating when it was created.

  • Pruning Archives:

    borg prune --prefix 'archive-name-' --keep-last 3 /path/to/your/repository
    

    This command removes older archives, keeping only the last three archives that match the specified prefix.

2. Extracting the Most Recent Archive

To extract the last archive created, you can use the following command:

borg extract --last /path/to/your/repository

Explanation of the Command:

  • borg extract: This is the primary command used for extracting archived data.
  • --last: This flag tells Borg to extract the most recently created archive.
  • /path/to/your/repository: Replace this with the actual path to your Borg repository where the archives are stored.

3. Additional Options

If you wish to extract a specific archive (if you want to avoid the '--last' option), you can list the archives first to get their names using:

borg list /path/to/your/repository

This will give you a list of all archives, and you can identify the one you need based on its name (which includes the creation date).

4. Full Example

Putting it all together, if you want to extract the most recent backup, you'd perform the commands as shown below:

# List all archives to confirm the latest one if needed
borg list /path/to/your/repository

# Extract the latest archive
borg extract --last /path/to/your/repository

Conclusion

Using the borg extract --last command is an efficient way to restore data from your latest backup without needing to specify the archive name manually. This command is designed to streamline the extraction process, particularly useful if you regularly create multiple archives. For further details and options, you can refer to the official Borg documentation on Borg Backup Documentation.

People Also Ask

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
borg-extract(1) — borgbackup — Debian testing
Manpages

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 ...

3
Extract only difference of latest backup : r/BorgBackup - Reddit
Reddit

Once you have the names of the two archives, run the difference as follows. borg diff REPOSITORY::OLD_ARCHIVE NEW_ARCHIVE.

4
Quick Start — Borg - Deduplicating Archiver 2.0.0b20.dev41 ...
Borgbackup

One can later extract or mount an archive to restore from a backup. Repositories are filesystem directories acting as self-contained stores of archives.

5
How to restore borg backups? - Andrey Albershtein
Alberand

If you want just the latest one add --last. Find the one you want to restore. They have dates in the name. With BorgBase you can also find out ...

6
Sort the output of a Borg Backup archive listing - Super User
Superuser

The command borg list $REPOSITORY::$ARCHIVE shows me a list of all files that are contained in a backup archive. That listing is unsorted (apparently).

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 backup - ArchWiki
Wiki

The removal of old archives is not performed automatically, but can be performed manually with the borg prune command. The number of archives to ...

9
Running a borg extract remotely - Unix & Linux Stack Exchange
Unix

Being able to perform a borg check remotely requires 1) that you can run commands on the remote server and 2) that borg is installed on the remote server.

10
How to extract a backup - torsion.org projects
Torsion

The first step is to figure out which archive to extract. A good way to do that is to use the repo-list action.