forked from borgmatic-collective/borgmatic
Compare commits
157 Commits
89cc4e824a
...
62d7835018
Author | SHA1 | Date | |
---|---|---|---|
62d7835018 | |||
caba5f8291 | |||
fcdd839278 | |||
daa0daab1b | |||
458b868371 | |||
e105799296 | |||
be1e483e66 | |||
ce040a1a2b | |||
fb92e1aec4 | |||
6de48fa5d8 | |||
85c62625c7 | |||
174ebcc99c | |||
3553cb0500 | |||
f6266160f9 | |||
eeb3cafe71 | |||
11798edc15 | |||
cbc6957a11 | |||
f8a81419c4 | |||
7adddb5a12 | |||
84a0ab3d18 | |||
5711151ad7 | |||
c53455c49d | |||
698468e322 | |||
71296cfa0d | |||
6be334d388 | |||
0aa554cfa5 | |||
74abc19df6 | |||
4c8600aa5d | |||
31b552df68 | |||
f2b2b3c984 | |||
1d79fa3910 | |||
c0ab5ae422 | |||
b1c6217047 | |||
bc662720df | |||
1f7f31098d | |||
df85d3e8d1 | |||
b48710b544 | |||
d5ad78d9af | |||
0ae811c25d | |||
4582cf5244 | |||
8edd5db1cb | |||
9e037af926 | |||
646370e675 | |||
7d1b8ed393 | |||
87bdc68fcd | |||
0940e9511d | |||
80091230d6 | |||
81c81792f7 | |||
a0810671bd | |||
c1a15d4cb4 | |||
9bff81ed1f | |||
419678e0a3 | |||
9af87e7035 | |||
baec8acbf8 | |||
a241b8a38b | |||
72effb99b1 | |||
f4b3681013 | |||
300d9b9dc4 | |||
52a64f6a2c | |||
91a916967c | |||
58798e0592 | |||
d0dce1c362 | |||
ed15ea932b | |||
e1a182418a | |||
26c83d1f62 | |||
0782ca6aef | |||
f0e92591cc | |||
0ada19b444 | |||
7129e20141 | |||
|
44f9e2d723 | ||
|
5c89ad6eda | ||
|
a0dbe93554 | ||
|
5af6d784bd | ||
|
9ded51b78a | ||
|
667a40cb0b | ||
|
c804793453 | ||
|
ef7b4c33ce | ||
dc2b1ff8d2 | |||
9f1d183712 | |||
6bf858aae2 | |||
|
4386e66f65 | ||
|
1cf4a91b0a | ||
9fa57b3190 | |||
15ca234349 | |||
fc9bf03409 | |||
e66afc8d8a | |||
8cac207fc6 | |||
e4fe56f526 | |||
e3c46d0084 | |||
4ef65a5411 | |||
850021b749 | |||
49564585dd | |||
01b4d7c27e | |||
dbb39d0b10 | |||
cd003f11dd | |||
ba71509bba | |||
b0a1ba867c | |||
13c16dd8f7 | |||
fa99471e3e | |||
1e8148575c | |||
6948aa957f | |||
61f1c9603c | |||
d854d40472 | |||
1804967bdc | |||
338a4cea29 | |||
41b3975198 | |||
f8f9debee8 | |||
c80f3c8265 | |||
4231405c80 | |||
15d408d7cf | |||
228f55a1de | |||
7beb935122 | |||
37a32b0943 | |||
24331d917c | |||
52889c646f | |||
49950c2c77 | |||
a66542cce1 | |||
ee8535f577 | |||
9071b14dcf | |||
713ed66337 | |||
608dbcedc7 | |||
67ed746024 | |||
3e8236c26e | |||
6bdb1974cf | |||
339ffc9c22 | |||
|
16da97d75d | ||
db13217361 | |||
f152e33f35 | |||
7ae1eac0df | |||
0241d56131 | |||
1c2ef7b24d | |||
1f12bf6461 | |||
2cf1ed57c0 | |||
deb46b0a70 | |||
25df602a47 | |||
7564a27dfc | |||
62109adfb0 | |||
|
abcd017e3e | ||
bf3d364ac4 | |||
c2622a4199 | |||
1e3fd59ce6 | |||
8f4c8200a6 | |||
a97dc48fee | |||
c54e6b319f | |||
e96ad5b854 | |||
a4111cc417 | |||
90fb6f5b9e | |||
7e49b63a26 | |||
df2c34c260 | |||
3ee7d502d3 | |||
e252f44696 | |||
58e3869dbd | |||
|
781e479966 | ||
3113aaba27 | |||
e5c762419c | |||
85a60ffa15 | |||
1c00954969 |
@ -24,6 +24,8 @@ clone:
|
||||
steps:
|
||||
- name: build
|
||||
image: alpine:3.13
|
||||
environment:
|
||||
TEST_CONTAINER: true
|
||||
pull: always
|
||||
commands:
|
||||
- scripts/run-full-tests
|
||||
|
@ -1,4 +1,5 @@
|
||||
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
|
||||
const codeClipboard = require("eleventy-plugin-code-clipboard");
|
||||
const inclusiveLangPlugin = require("@11ty/eleventy-plugin-inclusive-language");
|
||||
const navigationPlugin = require("@11ty/eleventy-navigation");
|
||||
|
||||
@ -6,6 +7,7 @@ module.exports = function(eleventyConfig) {
|
||||
eleventyConfig.addPlugin(pluginSyntaxHighlight);
|
||||
eleventyConfig.addPlugin(inclusiveLangPlugin);
|
||||
eleventyConfig.addPlugin(navigationPlugin);
|
||||
eleventyConfig.addPlugin(codeClipboard);
|
||||
|
||||
let markdownIt = require("markdown-it");
|
||||
let markdownItAnchor = require("markdown-it-anchor");
|
||||
@ -31,6 +33,7 @@ module.exports = function(eleventyConfig) {
|
||||
markdownIt(markdownItOptions)
|
||||
.use(markdownItAnchor, markdownItAnchorOptions)
|
||||
.use(markdownItReplaceLink)
|
||||
.use(codeClipboard.markdownItCopyButton)
|
||||
);
|
||||
|
||||
eleventyConfig.addPassthroughCopy({"docs/static": "static"});
|
||||
|
83
NEWS
83
NEWS
@ -1,5 +1,86 @@
|
||||
1.7.5.dev0
|
||||
1.7.11.dev0
|
||||
* #662: Fix regression in which "check_repositories" option failed to match repositories.
|
||||
|
||||
1.7.10
|
||||
* #396: When a database command errors, display and log the error message instead of swallowing it.
|
||||
* #501: Optionally error if a source directory does not exist via "source_directories_must_exist"
|
||||
option in borgmatic's location configuration.
|
||||
* #576: Add support for "file://" paths within "repositories" option.
|
||||
* #612: Define and use custom constants in borgmatic configuration files. See the documentation for
|
||||
more information:
|
||||
https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#constant-interpolation
|
||||
* #618: Add support for BORG_FILES_CACHE_TTL environment variable via "borg_files_cache_ttl" option
|
||||
in borgmatic's storage configuration.
|
||||
* #623: Fix confusing message when an error occurs running actions for a configuration file.
|
||||
* #635: Add optional repository labels so you can select a repository via "--repository yourlabel"
|
||||
at the command-line. See the configuration reference for more information:
|
||||
https://torsion.org/borgmatic/docs/reference/configuration/
|
||||
* #649: Add documentation on backing up a database running in a container:
|
||||
https://torsion.org/borgmatic/docs/how-to/backup-your-databases/#containers
|
||||
* #655: Fix error when databases are configured and a source directory doesn't exist.
|
||||
* Add code style plugins to enforce use of Python f-strings and prevent single-letter variables.
|
||||
To join in the pedantry, refresh your test environment with "tox --recreate".
|
||||
* Rename scripts/run-full-dev-tests to scripts/run-end-to-end-dev-tests and make it run end-to-end
|
||||
tests only. Continue using tox to run unit and integration tests.
|
||||
|
||||
1.7.9
|
||||
* #295: Add a SQLite database dump/restore hook.
|
||||
* #304: Change the default action order when no actions are specified on the command-line to:
|
||||
"create", "prune", "compact", "check". If you'd like to retain the old ordering ("prune" and
|
||||
"compact" first), then specify actions explicitly on the command-line.
|
||||
* #304: Run any command-line actions in the order specified instead of using a fixed ordering.
|
||||
* #564: Add "--repository" flag to all actions where it makes sense, so you can run borgmatic on
|
||||
a single configured repository instead of all of them.
|
||||
* #628: Add a Healthchecks "log" state to send borgmatic logs to Healthchecks without signalling
|
||||
success or failure.
|
||||
* #647: Add "--strip-components all" feature on the "extract" action to remove leading path
|
||||
components of files you extract. Must be used with the "--path" flag.
|
||||
* Add support for Python 3.11.
|
||||
|
||||
1.7.8
|
||||
* #620: With the "create" action and the "--list" ("--files") flag, only show excluded files at
|
||||
verbosity 2.
|
||||
* #621: Add optional authentication to the ntfy monitoring hook.
|
||||
* With the "create" action, only one of "--list" ("--files") and "--progress" flags can be used.
|
||||
This lines up with the new behavior in Borg 2.0.0b5.
|
||||
* Internally support new Borg 2.0.0b5 "--filter" status characters / item flags for the "create"
|
||||
action.
|
||||
* Fix the "create" action with the "--dry-run" flag querying for databases when a PostgreSQL/MySQL
|
||||
"all" database is configured. Now, these queries are skipped due to the dry run.
|
||||
* Add "--repository" flag to the "rcreate" action to optionally select one configured repository to
|
||||
create.
|
||||
* Add "--progress" flag to the "transfer" action, new in Borg 2.0.0b5.
|
||||
* Add "checkpoint_volume" configuration option to creates checkpoints every specified number of
|
||||
bytes during a long-running backup, new in Borg 2.0.0b5.
|
||||
|
||||
1.7.7
|
||||
* #642: Add MySQL database hook "add_drop_database" configuration option to control whether dumped
|
||||
MySQL databases get dropped right before restore.
|
||||
* #643: Fix for potential data loss (data not getting backed up) when dumping large "directory"
|
||||
format PostgreSQL/MongoDB databases. Prior to the fix, these dumps would not finish writing to
|
||||
disk before Borg consumed them. Now, the dumping process completes before Borg starts. This only
|
||||
applies to "directory" format databases; other formats still stream to Borg without using
|
||||
temporary disk space.
|
||||
* Fix MongoDB "directory" format to work with mongodump/mongorestore without error. Prior to this
|
||||
fix, only the "archive" format worked.
|
||||
|
||||
1.7.6
|
||||
* #393, #438, #560: Optionally dump "all" PostgreSQL/MySQL databases to separate files instead of
|
||||
one combined dump file, allowing more convenient restores of individual databases. You can enable
|
||||
this by specifying the database dump "format" option when the database is named "all".
|
||||
* #602: Fix logs that interfere with JSON output by making warnings go to stderr instead of stdout.
|
||||
* #622: Fix traceback when include merging configuration files on ARM64.
|
||||
* #629: Skip warning about excluded special files when no special files have been excluded.
|
||||
* #630: Add configuration options for database command customization: "list_options",
|
||||
"restore_options", and "analyze_options" for PostgreSQL, "restore_options" for MySQL, and
|
||||
"restore_options" for MongoDB.
|
||||
|
||||
1.7.5
|
||||
* #311: Override PostgreSQL dump/restore commands via configuration options.
|
||||
* #604: Fix traceback when a configuration section is present but lacking any options.
|
||||
* #607: Clarify documentation examples for include merging and deep merging.
|
||||
* #611: Fix "data" consistency check to support "check_last" and consistency "prefix" options.
|
||||
* #613: Clarify documentation about multiple repositories and separate configuration files.
|
||||
|
||||
1.7.4
|
||||
* #596: Fix special file detection erroring when broken symlinks are encountered.
|
||||
|
63
README.md
63
README.md
@ -24,9 +24,10 @@ location:
|
||||
|
||||
# Paths of local or remote repositories to backup to.
|
||||
repositories:
|
||||
- ssh://1234@usw-s001.rsync.net/./backups.borg
|
||||
- ssh://k8pDxu32@k8pDxu32.repo.borgbase.com/./repo
|
||||
- /var/lib/backups/local.borg
|
||||
- path: ssh://k8pDxu32@k8pDxu32.repo.borgbase.com/./repo
|
||||
label: borgbase
|
||||
- path: /var/lib/backups/local.borg
|
||||
label: local
|
||||
|
||||
retention:
|
||||
# Retention policy for how many backups to keep.
|
||||
@ -67,6 +68,7 @@ borgmatic is powered by [Borg Backup](https://www.borgbackup.org/).
|
||||
<a href="https://www.mysql.com/"><img src="docs/static/mysql.png" alt="MySQL" height="60px" style="margin-bottom:20px;"></a>
|
||||
<a href="https://mariadb.com/"><img src="docs/static/mariadb.png" alt="MariaDB" height="60px" style="margin-bottom:20px;"></a>
|
||||
<a href="https://www.mongodb.com/"><img src="docs/static/mongodb.png" alt="MongoDB" height="60px" style="margin-bottom:20px;"></a>
|
||||
<a href="https://sqlite.org/"><img src="docs/static/sqlite.png" alt="SQLite" height="60px" style="margin-bottom:20px;"></a>
|
||||
<a href="https://healthchecks.io/"><img src="docs/static/healthchecks.png" alt="Healthchecks" height="60px" style="margin-bottom:20px;"></a>
|
||||
<a href="https://cronitor.io/"><img src="docs/static/cronitor.png" alt="Cronitor" height="60px" style="margin-bottom:20px;"></a>
|
||||
<a href="https://cronhub.io/"><img src="docs/static/cronhub.png" alt="Cronhub" height="60px" style="margin-bottom:20px;"></a>
|
||||
@ -80,8 +82,8 @@ borgmatic is powered by [Borg Backup](https://www.borgbackup.org/).
|
||||
Your first step is to [install and configure
|
||||
borgmatic](https://torsion.org/borgmatic/docs/how-to/set-up-backups/).
|
||||
|
||||
For additional documentation, check out the links above for <a
|
||||
href="https://torsion.org/borgmatic/#documentation">borgmatic how-to and
|
||||
For additional documentation, check out the links above (left panel on wide screens)
|
||||
for <a href="https://torsion.org/borgmatic/#documentation">borgmatic how-to and
|
||||
reference guides</a>.
|
||||
|
||||
|
||||
@ -104,23 +106,38 @@ offerings, but do not currently fund borgmatic development or hosting.
|
||||
|
||||
### Issues
|
||||
|
||||
You've got issues? Or an idea for a feature enhancement? We've got an [issue
|
||||
tracker](https://projects.torsion.org/borgmatic-collective/borgmatic/issues). In order to
|
||||
create a new issue or comment on an issue, you'll need to [login
|
||||
first](https://projects.torsion.org/user/login). Note that you can login with
|
||||
an existing GitHub account if you prefer.
|
||||
|
||||
If you'd like to chat with borgmatic developers or users, head on over to the
|
||||
`#borgmatic` IRC channel on Libera Chat, either via <a
|
||||
href="https://web.libera.chat/#borgmatic">web chat</a> or a
|
||||
native <a href="ircs://irc.libera.chat:6697">IRC client</a>. If you
|
||||
don't get a response right away, please hang around a while—or file a ticket
|
||||
instead.
|
||||
Are you experiencing an issue with borgmatic? Or do you have an idea for a
|
||||
feature enhancement? Head on over to our [issue
|
||||
tracker](https://projects.torsion.org/borgmatic-collective/borgmatic/issues).
|
||||
In order to create a new issue or add a comment, you'll need to
|
||||
[register](https://projects.torsion.org/user/sign_up?invite_code=borgmatic)
|
||||
first. If you prefer to use an existing GitHub account, you can skip account
|
||||
creation and [login directly](https://projects.torsion.org/user/login).
|
||||
|
||||
Also see the [security
|
||||
policy](https://torsion.org/borgmatic/docs/security-policy/) for any security
|
||||
issues.
|
||||
|
||||
|
||||
### Social
|
||||
|
||||
Check out the [Borg subreddit](https://www.reddit.com/r/BorgBackup/) for
|
||||
general Borg and borgmatic discussion and support.
|
||||
|
||||
Also follow [borgmatic on Mastodon](https://fosstodon.org/@borgmatic).
|
||||
|
||||
|
||||
### Chat
|
||||
|
||||
To chat with borgmatic developers or users, check out the `#borgmatic`
|
||||
IRC channel on Libera Chat, either via <a
|
||||
href="https://web.libera.chat/#borgmatic">web chat</a> or a native <a
|
||||
href="ircs://irc.libera.chat:6697">IRC client</a>. If you don't get a response
|
||||
right away, please hang around a while—or file a ticket instead.
|
||||
|
||||
|
||||
### Other
|
||||
|
||||
Other questions or comments? Contact
|
||||
[witten@torsion.org](mailto:witten@torsion.org).
|
||||
|
||||
@ -135,10 +152,14 @@ borgmatic is licensed under the GNU General Public License version 3 or any
|
||||
later version.
|
||||
|
||||
If you'd like to contribute to borgmatic development, please feel free to
|
||||
submit a [Pull Request](https://projects.torsion.org/borgmatic-collective/borgmatic/pulls)
|
||||
or open an [issue](https://projects.torsion.org/borgmatic-collective/borgmatic/issues) first
|
||||
to discuss your idea. We also accept Pull Requests on GitHub, if that's more
|
||||
your thing. In general, contributions are very welcome. We don't bite!
|
||||
submit a [Pull
|
||||
Request](https://projects.torsion.org/borgmatic-collective/borgmatic/pulls) or
|
||||
open an
|
||||
[issue](https://projects.torsion.org/borgmatic-collective/borgmatic/issues) to
|
||||
discuss your idea. Note that you'll need to
|
||||
[register](https://projects.torsion.org/user/sign_up?invite_code=borgmatic)
|
||||
first. We also accept Pull Requests on GitHub, if that's more your thing. In
|
||||
general, contributions are very welcome. We don't bite!
|
||||
|
||||
Also, please check out the [borgmatic development
|
||||
how-to](https://torsion.org/borgmatic/docs/how-to/develop-on-borgmatic/) for
|
||||
|
0
borgmatic/actions/__init__.py
Normal file
0
borgmatic/actions/__init__.py
Normal file
36
borgmatic/actions/borg.py
Normal file
36
borgmatic/actions/borg.py
Normal file
@ -0,0 +1,36 @@
|
||||
import logging
|
||||
|
||||
import borgmatic.borg.borg
|
||||
import borgmatic.borg.rlist
|
||||
import borgmatic.config.validate
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_borg(
|
||||
repository, storage, local_borg_version, borg_arguments, local_path, remote_path,
|
||||
):
|
||||
'''
|
||||
Run the "borg" action for the given repository.
|
||||
'''
|
||||
if borg_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, borg_arguments.repository
|
||||
):
|
||||
logger.info('{}: Running arbitrary Borg command'.format(repository['path']))
|
||||
archive_name = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository['path'],
|
||||
borg_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path,
|
||||
remote_path,
|
||||
)
|
||||
borgmatic.borg.borg.run_arbitrary_borg(
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
options=borg_arguments.options,
|
||||
archive=archive_name,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
)
|
25
borgmatic/actions/break_lock.py
Normal file
25
borgmatic/actions/break_lock.py
Normal file
@ -0,0 +1,25 @@
|
||||
import logging
|
||||
|
||||
import borgmatic.borg.break_lock
|
||||
import borgmatic.config.validate
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_break_lock(
|
||||
repository, storage, local_borg_version, break_lock_arguments, local_path, remote_path,
|
||||
):
|
||||
'''
|
||||
Run the "break-lock" action for the given repository.
|
||||
'''
|
||||
if break_lock_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, break_lock_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository["path"]}: Breaking repository and cache locks')
|
||||
borgmatic.borg.break_lock.break_lock(
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
)
|
61
borgmatic/actions/check.py
Normal file
61
borgmatic/actions/check.py
Normal file
@ -0,0 +1,61 @@
|
||||
import logging
|
||||
|
||||
import borgmatic.borg.check
|
||||
import borgmatic.config.validate
|
||||
import borgmatic.hooks.command
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_check(
|
||||
config_filename,
|
||||
repository,
|
||||
location,
|
||||
storage,
|
||||
consistency,
|
||||
hooks,
|
||||
hook_context,
|
||||
local_borg_version,
|
||||
check_arguments,
|
||||
global_arguments,
|
||||
local_path,
|
||||
remote_path,
|
||||
):
|
||||
'''
|
||||
Run the "check" action for the given repository.
|
||||
'''
|
||||
if check_arguments.repository and not borgmatic.config.validate.repositories_match(
|
||||
repository, check_arguments.repository
|
||||
):
|
||||
return
|
||||
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('before_check'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'pre-check',
|
||||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info('{}: Running consistency checks'.format(repository['path']))
|
||||
borgmatic.borg.check.check_archives(
|
||||
repository['path'],
|
||||
location,
|
||||
storage,
|
||||
consistency,
|
||||
local_borg_version,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
progress=check_arguments.progress,
|
||||
repair=check_arguments.repair,
|
||||
only_checks=check_arguments.only,
|
||||
force=check_arguments.force,
|
||||
)
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('after_check'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'post-check',
|
||||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
65
borgmatic/actions/compact.py
Normal file
65
borgmatic/actions/compact.py
Normal file
@ -0,0 +1,65 @@
|
||||
import logging
|
||||
|
||||
import borgmatic.borg.compact
|
||||
import borgmatic.borg.feature
|
||||
import borgmatic.config.validate
|
||||
import borgmatic.hooks.command
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_compact(
|
||||
config_filename,
|
||||
repository,
|
||||
storage,
|
||||
retention,
|
||||
hooks,
|
||||
hook_context,
|
||||
local_borg_version,
|
||||
compact_arguments,
|
||||
global_arguments,
|
||||
dry_run_label,
|
||||
local_path,
|
||||
remote_path,
|
||||
):
|
||||
'''
|
||||
Run the "compact" action for the given repository.
|
||||
'''
|
||||
if compact_arguments.repository and not borgmatic.config.validate.repositories_match(
|
||||
repository, compact_arguments.repository
|
||||
):
|
||||
return
|
||||
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('before_compact'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'pre-compact',
|
||||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.COMPACT, local_borg_version):
|
||||
logger.info('{}: Compacting segments{}'.format(repository['path'], dry_run_label))
|
||||
borgmatic.borg.compact.compact_segments(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
progress=compact_arguments.progress,
|
||||
cleanup_commits=compact_arguments.cleanup_commits,
|
||||
threshold=compact_arguments.threshold,
|
||||
)
|
||||
else: # pragma: nocover
|
||||
logger.info(
|
||||
'{}: Skipping compact (only available/needed in Borg 1.2+)'.format(repository['path'])
|
||||
)
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('after_compact'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'post-compact',
|
||||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
96
borgmatic/actions/create.py
Normal file
96
borgmatic/actions/create.py
Normal file
@ -0,0 +1,96 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
import borgmatic.borg.create
|
||||
import borgmatic.config.validate
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.dispatch
|
||||
import borgmatic.hooks.dump
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_create(
|
||||
config_filename,
|
||||
repository,
|
||||
location,
|
||||
storage,
|
||||
hooks,
|
||||
hook_context,
|
||||
local_borg_version,
|
||||
create_arguments,
|
||||
global_arguments,
|
||||
dry_run_label,
|
||||
local_path,
|
||||
remote_path,
|
||||
):
|
||||
'''
|
||||
Run the "create" action for the given repository.
|
||||
|
||||
If create_arguments.json is True, yield the JSON output from creating the archive.
|
||||
'''
|
||||
if create_arguments.repository and not borgmatic.config.validate.repositories_match(
|
||||
repository, create_arguments.repository
|
||||
):
|
||||
return
|
||||
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('before_backup'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'pre-backup',
|
||||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info('{}: Creating archive{}'.format(repository['path'], dry_run_label))
|
||||
borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
|
||||
'remove_database_dumps',
|
||||
hooks,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
active_dumps = borgmatic.hooks.dispatch.call_hooks(
|
||||
'dump_databases',
|
||||
hooks,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
stream_processes = [process for processes in active_dumps.values() for process in processes]
|
||||
|
||||
json_output = borgmatic.borg.create.create_archive(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
location,
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
progress=create_arguments.progress,
|
||||
stats=create_arguments.stats,
|
||||
json=create_arguments.json,
|
||||
list_files=create_arguments.list_files,
|
||||
stream_processes=stream_processes,
|
||||
)
|
||||
if json_output: # pragma: nocover
|
||||
yield json.loads(json_output)
|
||||
|
||||
borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
|
||||
'remove_database_dumps',
|
||||
hooks,
|
||||
config_filename,
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('after_backup'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'post-backup',
|
||||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
48
borgmatic/actions/export_tar.py
Normal file
48
borgmatic/actions/export_tar.py
Normal file
@ -0,0 +1,48 @@
|
||||
import logging
|
||||
|
||||
import borgmatic.borg.export_tar
|
||||
import borgmatic.borg.rlist
|
||||
import borgmatic.config.validate
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_export_tar(
|
||||
repository,
|
||||
storage,
|
||||
local_borg_version,
|
||||
export_tar_arguments,
|
||||
global_arguments,
|
||||
local_path,
|
||||
remote_path,
|
||||
):
|
||||
'''
|
||||
Run the "export-tar" action for the given repository.
|
||||
'''
|
||||
if export_tar_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, export_tar_arguments.repository
|
||||
):
|
||||
logger.info(
|
||||
f'{repository["path"]}: Exporting archive {export_tar_arguments.archive} as tar file'
|
||||
)
|
||||
borgmatic.borg.export_tar.export_tar_archive(
|
||||
global_arguments.dry_run,
|
||||
repository['path'],
|
||||
borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository['path'],
|
||||
export_tar_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path,
|
||||
remote_path,
|
||||
),
|
||||
export_tar_arguments.paths,
|
||||
export_tar_arguments.destination,
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
tar_filter=export_tar_arguments.tar_filter,
|
||||
list_files=export_tar_arguments.list_files,
|
||||
strip_components=export_tar_arguments.strip_components,
|
||||
)
|
69
borgmatic/actions/extract.py
Normal file
69
borgmatic/actions/extract.py
Normal file
@ -0,0 +1,69 @@
|
||||
import logging
|
||||
|
||||
import borgmatic.borg.extract
|
||||
import borgmatic.borg.rlist
|
||||
import borgmatic.config.validate
|
||||
import borgmatic.hooks.command
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_extract(
|
||||
config_filename,
|
||||
repository,
|
||||
location,
|
||||
storage,
|
||||
hooks,
|
||||
hook_context,
|
||||
local_borg_version,
|
||||
extract_arguments,
|
||||
global_arguments,
|
||||
local_path,
|
||||
remote_path,
|
||||
):
|
||||
'''
|
||||
Run the "extract" action for the given repository.
|
||||
'''
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('before_extract'),
|
||||
hooks.get('umask'),
|
||||
config_filename,
|
||||
'pre-extract',
|
||||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||