Debian Codegraph @

doc/user-guide/14-ZYPPER-and-YUM.adoc

raw
1 == Documentation for the ZYPPER and YUM Methods
2
3 === Background
4
5 Both the ZYPPER and YUM methods are used to recreate a system "from scratch" by
6 capturing a list of RPMs installed on the source system and installing those RPMs
7 on the target system during the restore phase.
8
9 As of ReaR 2.4, the YUM method also includes the option to backup certain files.
10
11
12 == ZYPPER
13
14 NOTE: ZYPPER method support was added to Relax-and-Recover 2.1.
15
16 This is not the usual file-based backup/restore method where one gets the files
17 of an old system back as they had been before.
18
19 This new kind of "backup" method does not work on files but on RPM packages and
20 is intended for use with Linux distributions which use the zypper package
21 manager (SUSE, openSUSE, etc).
22
23 === Configuration
24
25 *Option: ZYPPER REPOSITORIES*
26
27 During `rear mkbackup` it will basically only save a list of installed RPM
28 packages into _var/lib/rear/backup/ZYPPER/installed_RPM_packages_ and during
29 `rear recover` it will basically only install those RPM packages as pristine
30 RPM packages from those zypper repositories that are specified in
31 _ZYPPER_REPOSITORIES_ or in a
32 _var/lib/rear/backup/ZYPPER/zypper_repositories.repo_ file.
33
34 Any other files that should be restored (e.g. prepared config files or
35 /home directories) must be done by "Using Multiple Backups for
36 Relax-and-Recover", see doc/user-guide/11-multiple-backups.adoc
37
38 For each member _zypper_repository_ in the _ZYPPER_REPOSITORIES_ array, the
39 following command is called
40 `zypper --root $TARGET_FS_ROOT addrepo $zypper_repository ...`
41 which means each array member in _ZYPPER_REPOSITORIES_ must be a valid zypper
42 repository URI.
43
44 See what `zypper repos -u` shows as URI and what `zypper repos -u -` returns.
45 Also see `man zypper`.
46
47 .Automatic zypper repo detection
48
49 The default empty _ZYPPER_REPOSITORIES_ array means that, during `rear mkbackup`, the command
50 `zypper repos --export var/lib/rear/backup/ZYPPER/zypper_repositories.repo`
51 is run (_var/lib/rear/backup/ZYPPER/zypper_repositories.repo_ gets included in
52 the ReaR recovery system) and when, during `rear recover` in the ReaR recovery
53 system, _/var/lib/rear/backup/ZYPPER/zypper_repositories.repo_ exists,
54 `zypper --root $TARGET_FS_ROOT addrepo --repo /var/lib/rear/backup/ZYPPER/zypper_repositories.repo`
55 is run in the ReaR recovery system so that by default during `rear recover` the same
56 zypper repositories are used as in the original system. A precondition for that is
57 that during `rear recover` those zypper repositories are somehow "just accessible".
58
59 ReaR has nothing implemented to make zypper repositories accessible.
60
61 If that precondition is not fulfilled one must explicitly specify in
62 _etc/rear/local.conf_ the _ZYPPER_REPOSITORIES_ array with appropriate valid
63 zypper repository URI value(s) that are "just accessible" during `rear recover`.
64
65 IMPORTANT: Currently the above described automated zypper repositories usage is not
66 implemented.
67 The current default is to use a SUSE installation DVD in the first CDROM drive: +
68 `ZYPPER_REPOSITORIES=( "cd:///?devices=/dev/sr0" )`
69
70 *Option: ZYPPER_INSTALL_RPMS*
71
72 ZYPPER_INSTALL_RPMS specifies which kind of RPM packages are installed in which
73 way for BACKUP=ZYPPER. The by default empty ZYPPER_INSTALL_RPMS means that,
74 during `rear recover`, each RPM package that is installed on the original
75 system gets re-installed on the target system. Plus, all RPM packages that are
76 required by the one that gets re-installed automatically.
77
78 The list of all installed RPMs is stored during `rear mkbackup` by default in
79 _var/lib/rear/backup/ZYPPER/installed_RPMs_.
80
81 With `ZYPPER_INSTALL_RPMS="independent_RPMs"`, only those RPM packages that are
82 not required by other RPM packages on the original system get re-installed
83 on the target system PLUS all RPM packages that are required and recommended
84 by the ones that gets re-installed.
85
86 RPM packages that are not required by other RPMs are independently installed
87 RPM packages. The list of independently installed RPMs is stored during `rear
88 mkbackup` by default in _var/lib/rear/backup/ZYPPER/independent_RPMs_.
89
90 Independently installed RPM packages are those that either are intentionally
91 installed by the admin (the ones that are really wanted) or got unintentionally
92 installed as recommended by other RPMs (those are perhaps needed) or are no
93 longer required after other RPMs had been removed (those are probably orphans).
94
95 *Option: COPY_AS_IS_ZYPPER and COPY_AS_IS_EXCLUDE_ZYPPER*
96
97 The COPY_AS_IS_ZYPPER array contains by default basically what `rpm -qc
98 zypper ; rpm -ql libzypp | grep -Ev 'locale|man'` shows (currently determined
99 on openSUSE Leap 42.1) plus the special _/etc/products.d/baseproduct_ link
100 and whereto it points and rpm because that is required by zypper/libzypp and
101 finally all kernel modules because otherwise modules like 'isofs' and some
102 'nls*' modules that are needed to mount a iso9660 image (e.g. a SUSE
103 installation medium in a CDROM drive) are not available in the ReaR recovery
104 system which can be a dead end for `rear recover`.
105
106 COPY_AS_IS_EXCLUDE_ZYPPER behaves the same as COPY_AS_IS_EXCLUDE, but
107 specifically for the ZYPPER method.
108
109 *Option: REQUIRED_PROGS_ZYPPER and PROGS_ZYPPER*
110
111 By default, the REQUIRED_PROGS_ZYPPER array contains all zypper, libzypp
112 and libsolv-tools binaries - i.e. all what `rpm -ql zypper | grep bin ; rpm -ql libzypp | grep bin ; rpm -ql libsolv-tools | grep bin`
113 shows (currently determined on openSUSE Leap 42.1) and all rpm binaries
114 because RPM is required by zypper/libzypp/libsolv-tools.
115
116 The PROGS_ZYPPER array is empty by default and intended to contain additional
117 useful programs that are not strictly required in the ReaR recovery system to
118 run `rear recover`.
119
120 *Option: ZYPPER_ROOT_PASSWORD*
121
122 ZYPPER_ROOT_PASSWORD specifies the initial root password in the target system.
123 This initial root password should not be the actually intended root password
124 because its value is stored in usually insecure files (e.g.
125 _/etc/rear/local.conf_) which are included in the ReaR recovery system that
126 is stored in also usually insecure files (like ISO images e.g.
127 `rear-HOSTNAME.iso`) so that the actually intended root password for the
128 target system should be set manually by the admin after `rear recover`.
129
130 As fallback `rear recover` sets 'root' as root password in the target system.
131
132 If SSH_ROOT_PASSWORD is specified it is used as root password in the target
133 system unless ZYPPER_ROOT_PASSWORD is specified, which is used with highest
134 priority.
135
136 *Option: ZYPPER_NETWORK_SETUP_COMMANDS*
137
138 ZYPPER_NETWORK_SETUP_COMMANDS specifies the initial network setup for the
139 target system.
140
141 This initial network setup is only meant to make the target system accessible
142 from remote in a very basic way (e.g. for 'ssh'). The actually intended
143 network setup for the target system should be done manually by the admin
144 after `rear recover`.
145
146 The by default empty ZYPPER_NETWORK_SETUP_COMMANDS array means that, during
147 `rear recover`, no network setup happens in the target system. The
148 ZYPPER_NETWORK_SETUP_COMMANDS array can be used for manual network setup, for
149 example, like `ZYPPER_NETWORK_SETUP_COMMANDS=( 'ip addr add 192.168.100.2/24 dev eth0' 'ip link set dev eth0 up' 'ip route add default via 192.168.100.1' )`
150 where each command in ZYPPER_NETWORK_SETUP_COMMANDS is run during
151 `rear recover` in the target system (via 'chroot'). When one of the
152 commands in ZYPPER_NETWORK_SETUP_COMMANDS is the special string
153 'NETWORKING_PREPARATION_COMMANDS', the commands in
154 NETWORKING_PREPARATION_COMMANDS are called inside the target system.
155
156 When one of the commands in ZYPPER_NETWORK_SETUP_COMMANDS is the special
157 string 'YAST', initial network setup in the target system happens by
158 calling the hardcoded command `yast2 --ncurses lan add name=eth0 ethdevice=eth0 bootproto=dhcp`.
159
160 If something else is needed, an appropriate yast2 command can be manually specified.
161
162 === Example
163 [source,bash]
164 OUTPUT=ISO
165 BACKUP=ZYPPER
166 BACKUP_OPTIONS="nfsvers=3,nolock"
167 BACKUP_URL=nfs://10.160.4.244/nfs
168 SSH_ROOT_PASSWORD='password_on_the_rear_recovery_system'
169 USE_DHCLIENT="yes"
170
171 == YUM
172
173 NOTE: YUM method support was added to Relax-and-Recover 2.3.
174
175 YUM is a port of the ZYPPER method for Linux distributions which use the yum
176 package manager, such as RHEL, CentOS, Fedora, etc.
177
178 Most options are the similar to, or the same as, the ZYPPER options. If a
179 particular option is not documented here, look at the equivalent ZYPPER_*
180 option.
181
182 *Option: YUM_EXCLUDE_PKGS*
183
184 Packages listed in this array will not be installed on the target
185 system, even if they are present on the source system.
186
187 This can be useful if, for instance, more than one kernel is installed
188 and you want to exclude the older kernel(s) from being installed on
189 the target system.
190
191 === Example
192 [source,bash]
193 OUTPUT=ISO
194 BACKUP=YUM
195 BACKUP_URL=iso://backup
196 OUTPUT_URL=null
197 YUM_EXCLUDE_PKGS=( 'kernel*327*' 'tree' )
198 export http_proxy="http://10.0.2.2:8080"
199
200 == YUM+backup
201
202 NOTE: YUM with file backup support was added to Relax-and-Recover 2.4.
203
204 This extension to the YUM method behaves a little differently than
205 folks usually expect: A full system backup is possible, but the
206 backup archive contains only the bare minimum files required to end
207 up with a full restore.
208
209 The backup archive is created in a similar manner as that used in
210 the NETFS method (tar.gz), but all files which have been installed
211 via RPM, and have not been modified, are excluded. All other files,
212 including those installed via RPM that have been modified, are
213 captured by the backup.
214
215 With file backup, ReaR will capture all modified configuration files,
216 user directories, custom scripts, etc without also storing all of the
217 files which ReaR will install as part of a package during recovery.
218
219 IMPORTANT: At present, YUM+backup has only been tested with `OUTPUT=ISO`.
220 Since files like _/etc/passwd_ will have been modified, they will, by
221 default, be included in the backup archive which is stored in the ISO.
222 *Any time that your backup archive is contained on the ISO, such as
223 with YUM+backup or NETFS, it is prudent to exercise proper security
224 so that the contents of the ISO do not fall into the wrong hands!*
225
226 === Configuration
227
228 *Option: YUM_BACKUP_FILES*
229
230 When set to a true value (yes, true, 1, etc), ReaR will create a
231 backup archive the files on the source which must be restored after
232 the packages are installed in order to result in a fully recovered
233 system.
234
235 === Options only available with YUM_BACKUP_FILES=yes
236
237 *Option: RECREATE_USERS_GROUPS*
238
239 This option determines if/how users and groups that are present on the
240 source system at the time that the backup is created, are recreated on the
241 target system.
242
243 By default, users and groups are not added to the target system during
244 `rear recover` unless they are added when a package is installed.
245
246 The `RECREATE_USERS_GROUPS="yes"` setting will tell ReaR to recreate all
247 users and groups on the target system, but passwords are locked.
248
249 Adding "passwords" to the RECREATE_USERS_GROUPS array
250 (`RECREATE_USERS_GROUPS=("yes" "passwords")`) will also set the target
251 system passwords.
252
253 *Option: YUM_BACKUP_FILES_FULL_EXCL*
254
255 This option determines if a comprehensive exclusion list is built
256 during backup.
257
258 The reason behind this option is that symlinks in file paths will
259 cause files which have been excluded (usually due to being provided
260 when a package is installed) to be implicitly included via the
261 alternate path(s) present on the system.
262
263 .Example
264 On a system where _/sbin_ is a symlink to _/usr/sbin_,
265 _/usr/sbin/ifup_ will be excluded due to being provided by the
266 initscripts package, but _/sbin/ifup_ will still be present in the
267 archive due to the alternate path.
268
269 [source,bash]
270 $ ls -ald /sbin
271 lrwxrwxrwx. 1 root root 8 Jun 15 2017 /sbin -> usr/sbin
272
273 A full, comprehensive exclusion list will find all paths to excluded
274 files, making the backup archive as small as possible, but can
275 potentially take a LOT longer due to the file system scans.
276
277 *Option: YUM_BACKUP_SELINUX_CONTEXTS*
278
279 ReaR can also capture the SELinux security contexts of every file
280 on the source system and reapply those contexts after the packages
281 have been reinstalled (and the backups, if any, have been extracted).
282
283 === Example
284 [source,bash]
285 OUTPUT=ISO
286 BACKUP=YUM
287 BACKUP_URL=iso://backup
288 OUTPUT_URL=null
289 BACKUP_SELINUX_DISABLE=0
290 YUM_BACKUP_FILES=yes
291 YUM_BACKUP_FILES_FULL_EXCL=yes
292 YUM_BACKUP_SELINUX_CONTEXTS=yes
293 RECREATE_USERS_GROUPS=( "yes" "passwords" )
294 export http_proxy="http://10.0.2.2:8080"
295