Newly downloaded archive is compared against existing files to ensure uniqueness
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
This commit is contained in:
parent
9bc7448cb3
commit
1a3efadea2
1 changed files with 19 additions and 2 deletions
|
@ -1,5 +1,22 @@
|
|||
#! /bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
basename=$(date +%s).tar.gz
|
||||
ld_backup_path="{{ ld_backup_path }}"
|
||||
backup_path=$ld_backup_path/$basename
|
||||
|
||||
wget -O "{{ ld_backup_path }}/$basename" "{{ ld_dump_url }}"
|
||||
# Find last modified
|
||||
recent=$(find "$ld_backup_path" -type f -name "*tar.gz" -mtime -1 | sort | tail -n 1)
|
||||
|
||||
wget -O "$backup_path" "{{ ld_dump_url }}"
|
||||
|
||||
# Extract both and get hashes
|
||||
new=$(tar -xzf "$backup_path" -O | sha256sum)
|
||||
old=$(tar -xzf "$recent" -O | sha256sum)
|
||||
|
||||
# Compare hashes
|
||||
if [ "$new" = "$old" ]; then
|
||||
echo No changes since last backup, removing downloaded archive
|
||||
rm "$recent"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue