#924 Issue closed: Missing cifs credentials file in rescue image

Labels: bug, documentation, fixed / solved / done

tcerna opened issue at 2016-07-18 08:41:

  • rear version (/usr/sbin/rear -V):
    rear-1.17.2-1.el7.noarch
  • OS version (cat /etc/rear/os.conf or lsb_release -a):
    RHEL-7
  • rear configuration files (cat /etc/rear/site.conf or cat /etc/rear/local.conf):
[root@rearclient ~]# cat /etc/rear/local.conf
OUTPUT=ISO
OUTPUT_URL=cifs://192.168.122.129/rear
OUTPUT_OPTIONS="cred=/etc/rear/.cifs"
BACKUP=NETFS
BACKUP_URL=cifs://192.168.122.129/rear
BACKUP_OPTIONS="cred=/etc/rear/.cifs"

[root@rearclient ~]# cat /etc/rear/.cifs
username=root 
password=root
  • Brief description of the issue:

Rescue image does not contain cifs credentials file specified during image & backup creation which causes an error during the backup restoration procedure. Even though this file can be manually recreated in rear's rescue shell, you should consider adding it to the final rescue image, especially when it is explicitly mentioned in the man page under BACKUP_URL=cifs:// section.

jsmeix commented at 2016-07-18 10:18:

Regardless that I don't know about cifs:

In general when something is missing
in the rear recovery system ("rescue image"),
you can specify what you need therein via

COPY_AS_IS=( "${COPY_AS_IS[@]}" /path/to/file1 /path/to/file2 )
REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}" program1 program2 )

See usr/share/rear/conf/default.conf

For an example you may have a look at
usr/share/rear/conf/examples/SLE12-SP1-btrfs-example.conf

In particular to get those automatocally for cifs
you need to implement something appropriate
in the rear scripts that works for you and
then provide that as Github pull request.

jsmeix commented at 2016-07-22 11:16:

@tcerna
does it work for you with appropriate COPY_AS_IS
and/or REQUIRED_PROGS settings?

jsmeix commented at 2016-07-29 10:24:

No feedback.
Assuming no news is good news.
Closing.

jsmeix commented at 2016-08-01 12:29:

By chance I noticed in
https://github.com/rear/rear/issues/943#issue-167618522

BACKUP_URL="cifs://192.168.0.13/g/BACKUPS/rear"
BACKUP_OPTIONS="cred=/etc/rear/creds"

I tested what happens when one has

etc/rear/.cifs

versus

etc/rear/cifs

and - guess what - etc/rear/.cifs does not get
automatically copied into the rear recovery system
but etc/rear/cifs gets automatically copied into
the rear recovery system.

Therefore there is a bug in the man page.
Instead of using a dot file it should describe
using a normal file name.

jsmeix commented at 2016-08-01 12:37:

The reason is in
usr/share/rear/build/GNU/Linux/10_copy_as_is.sh
that code:

### Copy configuration directory
mkdir $v -p $ROOTFS_DIR/etc/rear
cp $v -r $CONFIG_DIR/* $ROOTFS_DIR/etc/rear/ >&2

jsmeix commented at 2016-08-01 12:54:

With https://github.com/rear/rear/pull/947 merged
I consider the issue to be fixed.

gdha commented at 2016-08-01 14:27:

@jsmeix what prevents us from doing cp $v -r $CONFIG_DIR/ $ROOTFS_DIR/etc/ >&2 to also include the dot files? And, the mkdir line wouldn't be needed as well then...

jsmeix commented at 2016-08-02 11:33:

@gdha
there are no comments in the code that explain
why the code is as it is so that I cannot know
why dot files are not copied.
I assumed this behaviour is intentional but I did not want
to do forensics in this case to find out what might be
actually meant with this code.
Therefore I simply adapted the documentation to match
what the current code does.

jsmeix commented at 2016-08-02 11:39:

FYI, some forensics:
git log -p usr/share/rear/build/GNU/Linux/10_copy_as_is.sh
shows this inital commit where that code was added:

commit 28bac7ad4e6ab67e4e955fec27fc3556082c896e
Author: Jeroen Hoekx 
Date:   Wed Apr 3 11:39:56 2013 +0200
    Add option to set configuration directory from command line.
...
+### Copy configuration directory
+mkdir $v -p $ROOTFS_DIR/etc/rear
+cp $v -r $CONFIG_DIR/* $ROOTFS_DIR/etc/rear/

a bit later it was changed to

+cp $v -r $CONFIG_DIR/* $ROOTFS_DIR/etc/rear/ >&2

Perhaps it never was intentional that dot files are not copied?

jsmeix commented at 2016-08-02 11:43:

@gdha
when $CONFIG_DIR is not '/etc/rear' wouldn't then

cp .. $CONFIG_DIR/* $ROOTFS_DIR/etc

be wrong because shouldn't then also the $CONFIG_DIR
value be used as target directory in the recovery system?

gdha commented at 2016-08-02 13:07:

@jsmeix indeed you are right - forget about it - close it again

gdha commented at 2016-08-05 15:27:

@jsmeix Sorry couldn't help to get files starting with a dot on-board:
cp $v -r $CONFIG_DIR/.[a-z]* $ROOTFS_DIR/etc/rear/ >&2
It is working - now I'm pleased as well:

# ls -a /tmp/rear.Pp6tp8LYOttYS0c/rootfs/etc/rear
.  ..  .cifs  local.conf  local-lab-with-bareos.conf  local-with-nfs.conf  os.conf  rescue.conf

jsmeix commented at 2016-08-08 09:19:

For me it is perfectly fine when it also works for dot files.


[Export of Github issue for rear/rear.]