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 14, 2023
1 parent 0858fbf commit 39382b4
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 @@ -14,7 +14,7 @@
shell: >
if test -f {{ item }}; then
mkdir -p {{ __ssh_test_backup.path }}/$(dirname {{ item }});
cp {{ item }} {{ __ssh_test_backup.path }}/$(dirname {{ item }})
cp -a {{ item }} {{ __ssh_test_backup.path }}/$(dirname {{ item }})
fi
changed_when: false
loop: "{{ __ssh_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 @@ -2,7 +2,7 @@
- name: Restore backed up files and remove what was not present
shell: >
if test -f {{ __ssh_test_backup.path }}/{{ item }}; then
cp {{ __ssh_test_backup.path }}/{{ item }} $(dirname {{ item }})
cp -a {{ __ssh_test_backup.path }}/{{ item }} $(dirname {{ item }})
elif test -f {{ item }}; then
rm {{ item }}
fi
Expand Down

0 comments on commit 39382b4

Please sign in to comment.