Skip to content

Commit

Permalink
Various improvements ...
Browse files Browse the repository at this point in the history
Output messages from borg repo-create command
Refine the initial configurations
Improve the default command aliases.
Use --local by default for remote configurations with overdue command.
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Feb 3, 2025
1 parent fd68e10 commit 2a10892
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 67 deletions.
6 changes: 6 additions & 0 deletions assimilate/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,11 @@ def run(cls, command, args, settings, options):
cmd="repo-create",
assimilate_opts = cmdline
)
out = (borg.stderr or borg.stdout).rstrip()
if out:
out = out.replace('borg repo-space', 'assimilate repo-space')
out = out.replace('borg key export -r REPOSITORY', 'assimilate borg key export -r @repo')
output(out)
if borg.status:
return borg.status

Expand All @@ -2234,6 +2239,7 @@ def run(cls, command, args, settings, options):
borg_opts = [f"--reserve={space}"],
assimilate_opts = cmdline
)

out = borg.stderr or borg.stdout
if out:
output(out.rstrip())
Expand Down
2 changes: 1 addition & 1 deletion assimilate/overdue.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def get_remote_data(name, host, config, cmd):
display(f"\n{name}:")
config = ['--config', config] if config else []
try:
ssh = Run(['ssh', host] + config + cmd.split() + ['--nt'], 'sOEW1')
ssh = Run(['ssh', host] + config + cmd.split() + ['--nt', '--local'], 'sOEW1')
for repo_data in nt.loads(ssh.stdout, top=list):
if 'description' not in repo_data:
repo_data['description'] = repo_data.get('host', '')
Expand Down
66 changes: 38 additions & 28 deletions assimilate/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@
command aliases:
repo-list:
- archives
- a
- recent --last=20
list: paths
list:
- paths
- l
- ln -N
- ls -S
- ld -D
overdue: od
umount: unmount
# composite log file
logging:
Expand All @@ -109,20 +117,17 @@
overdue:
max age: 36 h
message: {description}: {updated} ago{locked: (currently active)}{overdue: — PAST DUE}
# repositories:
# # local
# cache@❬host❭ (/home/❬user❭):
# config: cache
# max age: 15m
# home@❬host❭ (/home/❬user❭):
# config: home2
# root@❬host❭ (/):
# config: root
# sentinel dir: ~root/.local/share/assimilate
#
# # remote
# ❬remote-host❭:
# host: ❬remote-host❭
repositories:
# local
cache@❬host❭ (/home/❬user❭):
config: cache
max age: 15m
home@❬host❭ (/home/❬user❭):
config: home
# remote
❬remote-host❭:
host: ❬remote-host❭
""", strip_nl='l')

# Root settings {{{3
Expand Down Expand Up @@ -187,13 +192,15 @@
# directories to be backed up
- R ~
# directories/files to be excluded
- - ~/.cache
# patterns are applied in order
# get rid of some always uninteresting files early so they do not get
# pulled back in by inclusions later
- - **/*~
- - **/__pycache__
- - **/*.pyc
- - **/.*.swp
- - **/.*.swo
- - **/.*.sw[ponml]
# directories/files to be excluded
- - .cache
# prune settings
keep within: 1d
Expand Down Expand Up @@ -223,16 +230,19 @@
# directories to be backed up
- R ~
# directories/files to be excluded
- - ~/music
- - ~/videos
- - ~/photos
- - ~/.cache
# patterns are applied in order
# get rid of some always uninteresting files early so they do not get
# pulled back in by inclusions later
- - **/*~
- - **/__pycache__
- - **/*.pyc
- - **/.*.swp
- - **/.*.swo
- - **/.*.sw[ponml]
- - **/.sw[ponml]
# directories/files to be excluded
- - Music
- - Videos
- - Pictures
- - .cache
# prune settings
keep within: 1d
Expand Down
20 changes: 12 additions & 8 deletions doc/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ suffix. It might look like the following:
# directories to be backed up
- R ~
# directories/files to be excluded
- - ~/.cache
# patterns are applied in order
# get rid of some always uninteresting files early so they do not get
# pulled back in by inclusions later
- - **/*~
- - **/__pycache__
- - **/*.pyc
- - **/.*.swp
- - **/.*.swo
- - **/.*.sw[ponml]
# specific directories/files to be excluded
- - ~/.cache
# prune settings
keep within: 2d
Expand Down Expand Up @@ -399,7 +401,10 @@ Patterns are an alternate way of specifying which files are backed up, and which
are not. Patterns can be specified in conjunction with, or instead of,
:ref:`src_dirs` and :ref:`excludes`. One powerful feature of patterns is that
they allow you to specify that a directory or file should be backed up even if
it is contained within a directory that is being excluded.
it is contained within a directory that is being excluded. The patterns are
processed in the order given, so in this example the pattern that matches the
file to be included should be given before the pattern that matches the
containing directory that is to be excluded.

An example that uses :ref:`patterns` in lieu of :ref:`src_dirs` and
:ref:`excludes` is:
Expand Down Expand Up @@ -441,8 +446,7 @@ and ``-`` specifies a path that should be excluded. With this example,
/usr/local is included while all other files and directories in /usr are not.
The subdirectory to include must be specified before the directory that contains
it is excluded. This is a relatively simple example, additional features are
described in the `Borg patterns documentation
<https://borgbackup.readthedocs.io/en/stable/usage/help.html>`_.
described in BorgPatterns_.


.. _retention:
Expand Down
33 changes: 19 additions & 14 deletions doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ And here is the contents of the *root* configuration file:
> R /opt
> R /usr/local
# directories/files to be excluded
# specific directories/files to be excluded
> - /var/cache
> - /var/lock
> - /var/run
Expand Down Expand Up @@ -242,13 +242,16 @@ be run interactively, perhaps once per day.
# directories to be backed up
- R ~
# directories/files to be excluded
- - ~/.cache
# patterns are applied in order
# get rid of some always uninteresting files early so they do not get
# pulled back in by inclusions later
- - **/*~
- - **/__pycache__
- - **/*.pyc
- - **/.*.swp
- - **/.*.swo
- - **/.*.sw[ponml]
# specific directories/files to be excluded
- - ~/.cache
- - ~/tmp
# prune settings
keep within: 1d
Expand Down Expand Up @@ -320,16 +323,18 @@ And finally, here is the contents of the *snapshots* configuration file:
# directories to be backed up
- R ~
# directories/files to be excluded
- - ~/music
- - ~/videos
- - ~/photos
- - ~/.cache
# patterns are applied in order
# get rid of some always uninteresting files early so they do not get
# pulled back in by inclusions later
- - **/*~
- - **/__pycache__
- - **/*.pyc
- - **/.*.swp
- - **/.*.swo
- - **/.*.sw[ponml]
# specific directories/files to be excluded
- - ~/Music
- - ~/Videos
- - ~/Pictures
- - ~/.cache
# prune settings
keep within: 1d
Expand Down
1 change: 1 addition & 0 deletions doc/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.. _BorgBackup: https://borgbackup.readthedocs.io
.. _BorgBase: https://www.borgbase.com
.. _BorgMatic: https://torsion.org/borgmatic
.. _BorgPatterns: https://borgbackup.readthedocs.io/en/master/usage/help.html#borg-help-patterns
.. _Duplicity: http://duplicity.nongnu.org
.. _Emborg: https://emborg.readthedocs.io/en/stable
.. _GitHub: https://github.com/KenKundert/assimilate/issues
Expand Down
4 changes: 4 additions & 0 deletions doc/migrating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ Before starting, it is useful to carefully read the documentation for the *Borg
and related settings. *archive* should be chosen to match the archives in
your *Borg 1* repository.

You should choose *archive* or *match_archives* settings to match the
archive naming of your old repository. In addition, you should choose
*working_dir* to maintain the same root paths.

**Step 2**:

Now create the new *Borg 2* repository
Expand Down
Loading

0 comments on commit 2a10892

Please sign in to comment.