Debian: Backup and Restore fixes for home dir

On Debian  /home is a symlink to /var/home

The following items are now fixed on Debian:
 - disk usage of /home would have always returned zero.
 - The backup of the /home directory would have only
included a symlink, and none of the contents.
 - The restore would have failed due to not finding a
valid /home subdirectory from a Debian backup.
 - The restore can now detect /var/home and extract it
if it exists, otherwise extracting /home (ie: CentOS)

Test Plan:
 PASS: Backup(Centos) / Restore(CentOS)
 PASS: Backup(Debian) / Restore(Debian)

Closes-Bug: #1980980
Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I564c05822483f2b3fcd9f20320b0445a97d7f399
This commit is contained in:
Al Bailey
2022-07-14 16:53:02 +00:00
parent 3e3864e542
commit 83db92c940
3 changed files with 25 additions and 4 deletions

View File

@@ -224,7 +224,7 @@
shell: "du -sh -k {{ item }} | awk '{print $1}'"
with_items:
- /etc
- /home
- "{{ homedir }} "
- "{{ config_permdir }}"
- "{{ sysinv_permdir }}"
- "{{ puppet_permdir }}/hieradata"
@@ -506,7 +506,7 @@
shell: "tar -czf {{ platform_backup_file_path }} $(ls -d \
{{ override_backup_file }} \
/etc \
/home \
{{ homedir }} \
{{ config_permdir }} \
{{ sysinv_permdir }} \
{{ puppet_permdir }}/hieradata \

View File

@@ -29,8 +29,12 @@
msg: "Backup can only be done on the active controller."
when: active_ctlr.rc != 0
- name: Declare homedir fact
set_fact:
homedir: "{{ '/home' if os_release == 'centos' else '/var/home' }}"
- name: Check disk usage of /home directory
shell: "du -sh -m /home | awk '{print $1}'"
shell: "du -sh -m {{ homedir }} | awk '{print $1}'"
register: home_dir_usage
- name: Fail if disk usage of /home directory is over {{ max_home_dir_usage }}MB

View File

@@ -253,8 +253,25 @@
path: "{{ staging_dir }}/ldap.db"
state: absent
# In order to determine the home dir pattern of the backed up data
# we only check var/home and use that to know how to extract.
# /var/home will exist on Debian, and not on CentOS. Cannot use /home
# because it exists in both (a directory vs a symlink)
# This enables home directory content of a CentOS backup to be restored
# on Debian during upgrade.
- name: Check if var/home directory is in the backup tarball
command: "tar -tf {{ restore_data_file }} var/home"
args:
warn: false
failed_when: false
register: debian_homedir
- name: Set the home directory to extract
set_fact:
home_dir_pattern: "{{ 'var/home/*' if debian_homedir.rc == 0 else 'home/*' }} "
- name: Restore home directory
shell: tar -C / --wildcards --overwrite -xpf {{ restore_data_file }} 'home/*'
shell: tar -C / --wildcards --overwrite -xpf {{ restore_data_file }} {{ home_dir_pattern }}
args:
warn: false
become_user: root