Enabling reading dirlist from file
This commit is contained in:
37
backup.sh
37
backup.sh
@@ -16,7 +16,10 @@ export GNUPGHOME="$(mktemp -d)"
|
||||
|
||||
bucket="${1}" ; shift
|
||||
name="${1}" ; shift
|
||||
backup_source="${1}" ; shift
|
||||
backup_sources_file="${1}" ; shift
|
||||
|
||||
declare -a backup_sources
|
||||
readarray backup_sources < "${backup_sources_file}"
|
||||
|
||||
install --directory --owner $(id -u) --group $(id -g) --mode 700 "${GNUPGHOME}"
|
||||
|
||||
@@ -29,6 +32,7 @@ trap cleanup EXIT
|
||||
tmpgpg() {
|
||||
gpg \
|
||||
--batch \
|
||||
--keyid-format=0xlong \
|
||||
--no-default-keyring \
|
||||
--no-options \
|
||||
--trust-model always \
|
||||
@@ -36,20 +40,29 @@ tmpgpg() {
|
||||
}
|
||||
|
||||
tmpgpg --import "${dir}/pubkey.asc"
|
||||
find \
|
||||
"${backup_source}" \
|
||||
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 "${backup_source}.*nextcloud/.*/files_trashbin" \
|
||||
-regex "${dir}.*/files_trashbin" \
|
||||
-o \
|
||||
-regex "${backup_source}.*nextcloud/nextcloud.log" \
|
||||
-regex "${dir}.*nextcloud.log.*" \
|
||||
-o \
|
||||
-regex "${backup_source}.*registry/docker/registry" \
|
||||
-regex "${dir}.*registry/docker/registry" \
|
||||
-o \
|
||||
-regex "${backup_source}.*gogs/.*/gogs.log.*" \
|
||||
-regex "${dir}.*/gogs.log.*" \
|
||||
-o \
|
||||
-regex "${backup_source}.*gogs/gogs/data/sessions/.*" \
|
||||
-regex "${dir}.*gogs/data/sessions/.*" \
|
||||
-o \
|
||||
-regex "${backup_source}.*/cache/.*" \
|
||||
-regex "${dir}.*/cache/.*" \
|
||||
\) \
|
||||
-prune \
|
||||
-o \
|
||||
@@ -63,6 +76,7 @@ find \
|
||||
--selinux \
|
||||
--xattrs \
|
||||
--null \
|
||||
--force-local \
|
||||
--no-recursion \
|
||||
--files-from - \
|
||||
--file - \
|
||||
@@ -74,6 +88,7 @@ find \
|
||||
--recipient 0x078A167A8741BD30 \
|
||||
| aws \
|
||||
s3 cp \
|
||||
--storage-class=DEEP_ARCHIVE \
|
||||
- \
|
||||
"s3://${bucket}/${name}-$(date --utc -Iseconds).tar.gz.gpg"
|
||||
"s3://${bucket}/${name}-${timestamp}/${dir}.tar.gz.gpg"
|
||||
done
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user