Skip to content

Commit

Permalink
Some improvement in locale handling for Borg
Browse files Browse the repository at this point in the history
Still not perfect though ...
  • Loading branch information
gozora committed Oct 12, 2016
1 parent 4367c62 commit c7dc42d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 2 additions & 3 deletions usr/share/rear/conf/default.conf
Expand Up @@ -626,8 +626,7 @@ BEXTRACT_DEVICE=
##
# TODO
# Copy Borg stuff 1:1
# Investigate propper locales setup in ReaR recovery media
COPY_AS_IS_BORG=( /usr/lib/locale/en_US.utf8 /usr/share/locale/en_US )
COPY_AS_IS_BORG=( )
# Binaries Borg needs to operate correctly
PROGS_BORG=( borg locale )
# Borg server name
Expand All @@ -641,7 +640,7 @@ BORG_REPO=
BORG_ARCHIVE_PREFIX="rear"
# Compression used by Borg
# Syntax: <compression_type,level>
# compression_type: lz4, zlib, lzma
# compression_type: none, lz4, zlib, lzma
# level: 0-9
BORG_COMPRESSION="zlib,9"
# TODO
Expand Down
5 changes: 5 additions & 0 deletions usr/share/rear/prep/BORG/default/10_prep_borg.sh
Expand Up @@ -3,5 +3,10 @@
#
# 10_prep_borg.sh

# Create our own locales, used only for Borg restore
mkdir -p $ROOTFS_DIR/usr/lib/locale
localedef -f UTF-8 -i en_US $ROOTFS_DIR/usr/lib/locale/rear.UTF-8
StopIfError "Could not create locales"

COPY_AS_IS=( "${COPY_AS_IS[@]}" "${COPY_AS_IS_BORG[@]}" )
PROGS=( "${PROGS[@]}" "${PROGS_BORG[@]}" )
13 changes: 5 additions & 8 deletions usr/share/rear/restore/BORG/default/20_restore_borg.sh
Expand Up @@ -8,15 +8,12 @@
cd /mnt/local
StopIfError "Could not change directory to /mnt/local"

# This will need some more work...
# It looks like Borg, needs working locales in order to behave correctly.
# Locale handling is curently very primitive and tested only on SLES11 SP3.
# Copy of locales is handled by COPY_AS_IS_BORG in default.conf.
# For the future, we will need to find some way how to make locale setup in
# ReaR recovery medium more bullet proof
LC_ALL=en_US.UTF-8

# Start actual restore
# 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 :-/
LogPrint "Recovering from archive: $ARCHIVE"
LC_ALL=rear.UTF-8 \
borg extract --sparse $BORG_USERNAME@$BORG_HOST:$BORG_REPO::$ARCHIVE
StopIfError "Could not successfully finish Borg restore"

0 comments on commit c7dc42d

Please sign in to comment.