Use dynamic file listing script
This commit is contained in:
38
backup.sh
38
backup.sh
@@ -16,13 +16,10 @@ export GNUPGHOME="$(mktemp -d)"
|
|||||||
|
|
||||||
bucket="${1}" ; shift
|
bucket="${1}" ; shift
|
||||||
name="${1}" ; shift
|
name="${1}" ; shift
|
||||||
backup_sources_file="${1}" ; shift
|
filelist_script="${1}" ; shift
|
||||||
gpg_pubkey_file="${1}" ; shift
|
gpg_pubkey_file="${1}" ; shift
|
||||||
gpg_pubkey_id="${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}"
|
install --directory --owner $(id -u) --group $(id -g) --mode 700 "${GNUPGHOME}"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@@ -46,30 +43,12 @@ tmpgpg -k
|
|||||||
|
|
||||||
timestamp="$(date --utc -Iseconds)"
|
timestamp="$(date --utc -Iseconds)"
|
||||||
|
|
||||||
for backup_dir in "${backup_sources[@]}" ; do
|
"${filelist_script}" | while read filelist ; do
|
||||||
backup_dir_expanded=($(eval "echo $backup_dir"))
|
filepath="$(echo "$filelist" | cut -d ':' -f 1)"
|
||||||
for dir in "${backup_dir_expanded[@]}" ; do
|
fifo="$(echo "$filelist" | cut -d ':' -f 2)"
|
||||||
echo $dir
|
mkdir -p "$(dirname "${filepath}")"
|
||||||
set -x
|
echo "$fifo"
|
||||||
find \
|
<"$fifo" tar \
|
||||||
"${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 \
|
|
||||||
--create \
|
--create \
|
||||||
--verbose \
|
--verbose \
|
||||||
--no-auto-compress \
|
--no-auto-compress \
|
||||||
@@ -91,6 +70,5 @@ for backup_dir in "${backup_sources[@]}" ; do
|
|||||||
| aws \
|
| aws \
|
||||||
s3 cp \
|
s3 cp \
|
||||||
- \
|
- \
|
||||||
"s3://${bucket}/${name}-${timestamp}/${dir##/}.tar.gz.gpg"
|
"s3://${bucket}/${name}-${timestamp}/${filepath}.tar.gz.gpg"
|
||||||
done
|
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user