When using Duplicity for incremental backups, it creates a series of backup chains with timestamps. Each backup set contains metadata about when it was created, allowing you to restore files from specific points in time.
The key command to discover available backup points is:
duplicity collection-status file:///backup-folder
This will output a detailed list of all backup sets with their timestamps in UTC format. For a more concise date listing, you can pipe the output through grep:
duplicity collection-status file:///backup-folder | grep "Full\|Incremental"
The collection status output shows backup chains with timestamps like:
Full Sat Jan 15 03:00:00 2022
Incremental Mon Jan 17 03:00:00 2022
You can extract just the dates for a restore menu:
duplicity collection-status file:///backup-folder |
awk '/Full|Incremental/ {print $3" "$4" "$5" "$6" "$7}'
Once you've identified the desired restore point, use:
duplicity --restore-time "Sat Jan 15 03:00:00 2022" \
file:///backup-folder /path/to/restore
For more precise time-based restoration, ISO 8601 format works best:
duplicity --restore-time 2022-01-15T03:00:00Z \
file:///backup-folder /path/to/restore
For scripting purposes, you can generate a numbered menu of restore points:
#!/bin/bash
counter=1
duplicity collection-status file:///backup-folder |
awk '/Full|Incremental/ {print NR" "$0}' > /tmp/restore_options.txt
cat /tmp/restore_options.txt
read -p "Select backup number: " choice
timestamp=$(sed -n "${choice}p" /tmp/restore_options.txt | awk '{print $4" "$5" "$6" "$7" "$8}')
duplicity --restore-time "$timestamp" file:///backup-folder /path/to/restore
For machine-readable output, add this flag to collection-status:
duplicity --time-separator : collection-status file:///backup-folder
This converts spaces to colons in timestamps, making them easier to parse programmatically.
When working with Duplicity for incremental backups, it's crucial to understand how it organizes backup sets. Each backup consists of a full backup followed by incremental ones, all timestamped with their creation dates.
The collection-status
command provides detailed information about available backups:
duplicity collection-status file:///backup-folder
The command output will show available backup chains with their timestamps. Here's how to extract just the dates:
duplicity collection-status file:///backup-folder | grep "Full\|Incremental" | awk '{print $4}'
A typical output looks like:
Full Sat Jan 15 12:00:00 2023 Incremental Mon Jan 17 14:30:00 2023 Incremental Wed Jan 19 09:15:00 2023
Once you've identified the desired date, use the restore
command:
duplicity --restore-time "2023-01-17" file:///backup-folder /path/to/restore
For scripting purposes, you can store available dates in an array:
backup_dates=($(duplicity collection-status file:///backup-folder |
grep "Full\|Incremental" |
awk '{print $4 " " $5 " " $6 " " $7}'))
echo "Available backup dates:"
printf "%s\n" "${backup_dates[@]}"
To list only backups within a specific time range:
duplicity collection-status --time-from 20230101 --time-to 20230131 file:///backup-folder
Always verify backup integrity before restoration:
duplicity verify file:///backup-folder /original/path