App-BorgRestore
view release on metacpan or search on metacpan
script/borg-restore.pl view on Meta::CPAN
#!/usr/bin/perl -T
use strictures 2;
=head1 NAME
borg-restore.pl - Restore paths from borg backups
=head1 SYNOPSIS
borg-restore.pl [options] <path>
Options:
--help, -h short help message
--debug show debug messages
--quiet show only warnings and errors
--detail Output additional detail for some operations
(currently only --list)
--json Output JSON instead of human readable text
(currently only --list)
--update-cache, -u update cache files
--list [pattern] List paths contained in the backups, optionally
matching an SQLite LIKE pattern
--destination, -d <path> Restore backup to directory <path>
--time, -t <timespec> Automatically find newest backup that is at least
<time spec> old
--adhoc Do not use the cache, instead provide an
unfiltered list of archive to choose from
--version display the version of the program
Time spec:
Select the newest backup that is at least <time spec> old.
Format: <number><unit>
Units: s (seconds), min (minutes), h (hours), d (days), m (months = 31 days), y (year)
=head1 EXAMPLE USAGE
> borg-restore.pl bin/backup.sh
0: Sat. 2016-04-16 17:47:48 +0200 backup-20160430-232909
1: Mon. 2016-08-15 16:11:29 +0200 backup-20160830-225145
2: Mon. 2017-02-20 16:01:04 +0100 backup-20170226-145909
3: Sat. 2017-03-25 14:45:29 +0100 backup-20170325-232957
Enter ID to restore (Enter to skip): 3
INFO Restoring home/flo/bin/backup.sh to /home/flo/bin from archive backup-20170325-232957
=head1 DESCRIPTION
borg-restore.pl helps to restore files from borg backups.
It takes one path, looks for its backups, shows a list of distinct versions and
allows to select one to be restored. Versions are based on the modification
time of the file.
It is also possible to specify a time for automatic selection of the backup
that has to be restored. If a time is specified, the script will automatically
select the newest backup that is at least as old as the time value that is
passed and restore it without further user interaction.
B<borg-restore.pl --update-cache> has to be executed regularly, ideally after
creating or removing backups.
L<App::BorgRestore> provides the base features used to implement this script.
It can be used to build your own restoration script.
=cut
=head1 OPTIONS
=over 4
=item B<--help>, B<-h>
Show help message.
=item B<--debug>
Enable debug messages.
=item B<--quiet>
Reduce output by showing only show warnings and above (errors).
=item B<--detail>
Output additional detail information with some operations. Refer to the
specific options for more information. Currently only works with B<--list>
=item B<--json>
Output JSON instead of human readable text with some operations. Refer to the
specific options for more information. Currently only works with B<--list>
=item B<--update-cache>, B<-u>
Update the lookup database. You should run this after creating or removing a backup.
=item B<--list> B<[pattern]>
List paths contained in the backups, optionally matching an SQLite LIKE
pattern. If no % occurs in the pattern, the patterns is automatically wrapped
between two % so it may match anywhere in the path.
If B<--detail> is used, also outputs which archives contain a version of the
file. If the same version is part of multiple archives, only one archive is
shown.
If B<--json> is used, the output is JSON. Can also be combined with B<--detail>.
=item B<--destination=>I<path>, B<-d >I<path>
( run in 0.689 second using v1.01-cache-2.11-cpan-39bf76dae61 )