Skip to content

Commit

Permalink
tests: Ensure backup/restore preserves file attributes
Browse files Browse the repository at this point in the history
I noticed some test failures in tests that check ownership/permissions
of config files.  The tests were recently changed to reuse the same
VM, so I suspect config files were not being backed up/restored with
the correct file attributes.  Use `cp -a` to preserve all file
attributes.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Nov 17, 2023
1 parent 350a0e5 commit 24c1915
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/tasks/backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
set -eu
if test -f {{ item }}; then
mkdir -p {{ __sshd_test_backup.path }}/$(dirname {{ item }})
cp {{ item }} {{ __sshd_test_backup.path }}/$(dirname {{ item }})
cp -a {{ item }} {{ __sshd_test_backup.path }}/$(dirname {{ item }})
fi
changed_when: false
loop: "{{ __sshd_test_backup_files | d([]) }}"
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -o pipefail
fi
if test -f {{ __sshd_test_backup.path }}/{{ item }}; then
cp {{ __sshd_test_backup.path }}/{{ item }} $(dirname {{ item }})
cp -a {{ __sshd_test_backup.path }}/{{ item }} $(dirname {{ item }})
elif test -f {{ item }}; then
rm {{ item }}
fi
Expand Down

0 comments on commit 24c1915

Please sign in to comment.