-
-
Notifications
You must be signed in to change notification settings - Fork 268
Support for Borg #1037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Borg #1037
Conversation
|
In usr/share/rear/restore/BORG/default/40_restore_backup.sh In your documentation you sometimes write "borg" BorgBackup (short: Borg) is a deduplicating backup program. |
|
Didn't know about TARGET_FS_ROOT... I'll correct it. I've try to used "borg" (small 'b') when referencing command and Borg (capital 'B') everywhere else. I'll review documentation one more time. Thanks for your inputs. |
Small documentation improvements
|
If @gdha does not object, I will merge it tomorrow. FYI: I missed |
|
@gozora sure no problem with copying dot files (already did the same for CIFS in 1.19) to initrd rootfs |
|
@gozora Now that you got a fresh integration in your fingertips why don't you update the https://github.com/rear/rear/blob/master/doc/user-guide/10-integrating-external-backup.adoc document? |
| echo "" | ||
|
|
||
| # Display archive_cache file content and prompt user for archive to restore | ||
| while(true); do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gozora I am always afraid when a see a while(true) that the code might be caught in an endless loop. Are you 100% sure that that will never happen? If possible I would avoid this construction...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm with you here, I don't like it either. It is however unavoidable sometimes.
This part of code asks user, which archive he wants to restore, and code loops until user enters valid archive or decides to exit restore. I think it is safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in such a case it could be even mandatory
to let "rear recover" operate on the safe side
and loop (possibly endlessly) until the user
provided a valid response.
I think it could be unsafe if "rear recover" would
restore something (e.g. a default or fallback)
that was not explicitly confirmed by the user.
I think the only exception is when there is
only one archive available to be restored.
Then I think "rear recover" could also for Borg assume
that one should be restored in the same way as it works
e.g. for 'tar' where the one backup.tar.gz is "just restored".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words:
"if [ $archive_cache_lines -eq 1 ]; then"
it could perhaps be skipped to ask the user
if he wants to restore from that one Borg archive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about auto start when only one archive is present.
But I personally prefer to be asked, It could happen that only present archive is not that I'd like to restore (for whatever reason), this would avoid loosing time with restore ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is mostly matter of taste, we can vote :-)
My vote is for "always ask"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are a Borg user and you implemented it,
so that your point of view matters most and
"always ask" is perfectly o.k. for me - in particular
now after you explained why it is this way (the latter
is a hint about a possibly missing explanatory comment
it the code so that others understand the reason behind ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, ;-) I'm not an coding autocrat, so I have no problem change this behavior if someone requests it in the future ..
The point with comment is however relevant, I'll add it ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ;-)
|
10-integrating-external-backup.adoc looks fine for me. Unfortunately I've discovered it after coding was done (typical me ...). |
|
@gozora No, I was wondering if it could be improved then now was the right moment to update it so it makes more sense for (new) developers. However, if it is OK for you then it I'm glad to hear that. |
ThomasWaldmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of typos, maybe consider a spell checker or manually reading your stuff again.
BORG_* naming might get you into trouble, consider these reserved for usage by borg. You can use them, but then expect borg does something with them (now or in future) and use them according to borg docs.
| Relax-and-Recover can be used only to restore the disk layout of your system and boot loader. However, that means you are responsible for taking backups. And, more important, to restore these before you reboot recovered system. | ||
|
|
||
| However, we have sucessfully already integrated external backup programs within rear, such as Netbackup, EMC NetWorker, Tivoli Storage Manager, Data Protetctor to name a few commercial backup programs. Furthermore, open source external backup programs which are also working with rear are, Bacula, Bareos and Duplicity to name the most known ones. | ||
| However, we have sucessfully already integrated external backup programs within rear, such as Netbackup, EMC NetWorker, Tivoli Storage Manager, Data Protetctor to name a few commercial backup programs. Furthermore, open source external backup programs which are also working with rear are, Bacula, Bareos, Duplicity and Borg to name the most known ones. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
successfully
and i guess the comma after "are" should not be there?
| # 10_load_archives.sh | ||
|
|
||
| # Check if BORG_ARCHIVE_PREFIX is correctly set | ||
| # Using '_' could result to some unpleasant site effects, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side
| # Check if BORG_ARCHIVE_PREFIX is correctly set | ||
| # Using '_' could result to some unpleasant site effects, | ||
| # as this character is used as delimiter in latter `for' loop ... | ||
| # Excluding other non aplhanum characeters is not really necessary, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alphanumeric
characters
| # I'm sure archive handling can be done better, but no time for it now ... | ||
| if [[ $BORG_ARCHIVE_PREFIX =~ [^a-zA-Z0-9] ]] \ | ||
| || [[ -z $BORG_ARCHIVE_PREFIX ]]; then | ||
| Error "BORG_ARCHIVE_PREFIX must be alphanumeric non emply value only" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-empty
| has_binary borg | ||
| StopIfError "Could not find Borg binary" | ||
|
|
||
| # Query Borg server for repoitory information and store it to archive_cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repository
| # Query Borg server for repoitory information and store it to archive_cache. | ||
| # This should avoid repeatingly quering Borg server, which could be slow. | ||
| archive_cache=$TMP_DIR/borg_archive | ||
| borg list $BORG_USERNAME@$BORG_HOST:$BORG_REPO > $archive_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, didn't I see that above already? consider --short option.
| # This means empty repository | ||
| if [ $archive_cache_lines -eq 0 ]; then | ||
| Error "Borg repository $BORG_REPO on $BORG_HOST is empty" | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is that an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ThomasWaldmann That is in OS restore stage. Once you run restore and have nothing to restore from, there ain't much options left.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thought whether it could not just show an empty list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ThomasWaldmann
Let me roughly describe how ReaR restore works.
- Boot small ISO image that contains some base system (including your configuration at the time backup was running)
- Start restore with
rear recover - ReaR loads and and creates your file system layout
- ReaR starts restore of your data (this is stage when Borg comes to game)
- ReaR does some exit tasks like boot loader installation, etc.
As you can see outputting empty list will you no good ...
In my opinion result must be failure as you can't correctly restore your OS. Of course after such failure you can reconfigure ReaR recovery system to use different settings (e.g. different Borg repository, different file system layout) and try to run restore again.
| # This gives possibility to abort restore if repository doesn't contain | ||
| # desired archive, hence saves some time. | ||
| while(true); do | ||
| cat -n $archive_cache | awk '{print "["$1"]", $2,"\t"$3,$4,$5}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, here you use more than just $1. so ignore my --short suggestion.
| LogPrint "Recovering from Borg archive $ARCHIVE" | ||
| LC_ALL=rear.UTF-8 \ | ||
| borg extract --sparse $BORG_USERNAME@$BORG_HOST:$BORG_REPO::$ARCHIVE | ||
| StopIfError "Could not successfully finish Borg restore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this likely should consider rc=0 vs 1 vs 2.
| # Scope of LC_ALL is only within run of `borg extract'. | ||
| # This avoids Borg problems with restoring UTF-8 encoded files names in archive | ||
| # and should not interfere with remaining stages of rear recover. | ||
| # This is still not the ideal sollution, but best I can think of so far :-/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solution
|
@ThomasWaldmann And one more thanks for all the typos corrections. I'm obviously lost without spellchecker! |
|
@gozora |
|
@jsmeix :-) I basically don't, but @ThomasWaldmann gave me wake up call, and I realized how much work is actually done by spell checker for me! |
|
@gozora only a side note: CLEANUP_COMMAND="..." ... || $CLEANUP_C0MMAND Even with "set -eu" the bug would usually not appear |
|
@jsmeix heh, this might be tricky one, I guess you are looking for similar functionality like gcc have, which reports unused variable and (static) functions ... |
|
@jsmeix Maybe have a look on https://github.com/koalaman/shellcheck / |
|
@alxgu Some time ago I had a look at ShellCheck $ osc search ShellCheck | grep ^openSUSE openSUSE:Backports:SLE-12 ShellCheck openSUSE:Factory ShellCheck openSUSE:Leap:42.2 ShellCheck $ osc results -v devel:languages:haskell ShellCheck | grep succeeded openSUSE_Leap_42.1 x86_64 succeeded openSUSE_Factory_PowerPC_standard ppc64le succeeded openSUSE_Factory_PowerPC_standard ppc64 succeeded openSUSE_13.2_Ports_ppc ppc64le succeeded openSUSE_13.2_Ports_ppc ppc64 succeeded openSUSE_13.2 i586 succeeded openSUSE_13.2 x86_64 succeeded SLE_12_SP1_Backports ppc64le succeeded SLE_12_SP1_Backports x86_64 succeeded SLE_12_Backports ppc64le succeeded SLE_12_Backports x86_64 succeeded I will try it out soon... |
|
@ThomasWaldmann maybe one more off topic question. Is there any difference in doing: |
|
yes, it also deletes the .cache/borg/id. see borg delete --help. |
Applied corrections discussed in #1037 (about BORGBACKUP)
Hello all,
This pull request is for issue #1030 (add support for Borg Backup).
It was tested on following distros, with latest stable Borg release 1.0.7:
I'll update documentation soon, for now here are some hits on setup:
ssh <borg_user>@<borg_server>