Use dynamic file listing script

This commit is contained in:
Hannes Körber
2019-04-28 20:28:18 +02:00
parent 198f642e04
commit 4b817f45c6

View File

@@ -16,13 +16,10 @@ export GNUPGHOME="$(mktemp -d)"
bucket="${1}" ; shift
name="${1}" ; shift
backup_sources_file="${1}" ; shift
filelist_script="${1}" ; shift
gpg_pubkey_file="${1}" ; shift
gpg_pubkey_id="${1}" ; shift
declare -a backup_sources
readarray backup_sources < "${backup_sources_file}"
install --directory --owner $(id -u) --group $(id -g) --mode 700 "${GNUPGHOME}"
cleanup() {
@@ -46,30 +43,12 @@ tmpgpg -k
timestamp="$(date --utc -Iseconds)"
for backup_dir in "${backup_sources[@]}" ; do
backup_dir_expanded=($(eval "echo $backup_dir"))
for dir in "${backup_dir_expanded[@]}" ; do
echo $dir
set -x
find \
"${dir[@]}" \
\( \
-regex "${dir}.*/files_trashbin" \
-o \
-regex "${dir}.*nextcloud.log.*" \
-o \
-regex "${dir}.*registry/docker/registry" \
-o \
-regex "${dir}.*/gogs.log.*" \
-o \
-regex "${dir}.*gogs/data/sessions/.*" \
-o \
-regex "${dir}.*/cache/.*" \
\) \
-prune \
-o \
-print0 \
| tar \
"${filelist_script}" | while read filelist ; do
filepath="$(echo "$filelist" | cut -d ':' -f 1)"
fifo="$(echo "$filelist" | cut -d ':' -f 2)"
mkdir -p "$(dirname "${filepath}")"
echo "$fifo"
<"$fifo" tar \
--create \
--verbose \
--no-auto-compress \
@@ -91,6 +70,5 @@ for backup_dir in "${backup_sources[@]}" ; do
| aws \
s3 cp \
- \
"s3://${bucket}/${name}-${timestamp}/${dir##/}.tar.gz.gpg"
done
"s3://${bucket}/${name}-${timestamp}/${filepath}.tar.gz.gpg"
done