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
|
bucket="${1}" ; shift
|
||||||
name="${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}"
|
install --directory --owner $(id -u) --group $(id -g) --mode 700 "${GNUPGHOME}"
|
||||||
|
|
||||||
@@ -29,6 +32,7 @@ trap cleanup EXIT
|
|||||||
tmpgpg() {
|
tmpgpg() {
|
||||||
gpg \
|
gpg \
|
||||||
--batch \
|
--batch \
|
||||||
|
--keyid-format=0xlong \
|
||||||
--no-default-keyring \
|
--no-default-keyring \
|
||||||
--no-options \
|
--no-options \
|
||||||
--trust-model always \
|
--trust-model always \
|
||||||
@@ -36,20 +40,29 @@ tmpgpg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpgpg --import "${dir}/pubkey.asc"
|
tmpgpg --import "${dir}/pubkey.asc"
|
||||||
find \
|
tmpgpg -k
|
||||||
"${backup_source}" \
|
|
||||||
|
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 \
|
-o \
|
||||||
-regex "${backup_source}.*nextcloud/nextcloud.log" \
|
-regex "${dir}.*nextcloud.log.*" \
|
||||||
-o \
|
-o \
|
||||||
-regex "${backup_source}.*registry/docker/registry" \
|
-regex "${dir}.*registry/docker/registry" \
|
||||||
-o \
|
-o \
|
||||||
-regex "${backup_source}.*gogs/.*/gogs.log.*" \
|
-regex "${dir}.*/gogs.log.*" \
|
||||||
-o \
|
-o \
|
||||||
-regex "${backup_source}.*gogs/gogs/data/sessions/.*" \
|
-regex "${dir}.*gogs/data/sessions/.*" \
|
||||||
-o \
|
-o \
|
||||||
-regex "${backup_source}.*/cache/.*" \
|
-regex "${dir}.*/cache/.*" \
|
||||||
\) \
|
\) \
|
||||||
-prune \
|
-prune \
|
||||||
-o \
|
-o \
|
||||||
@@ -63,6 +76,7 @@ find \
|
|||||||
--selinux \
|
--selinux \
|
||||||
--xattrs \
|
--xattrs \
|
||||||
--null \
|
--null \
|
||||||
|
--force-local \
|
||||||
--no-recursion \
|
--no-recursion \
|
||||||
--files-from - \
|
--files-from - \
|
||||||
--file - \
|
--file - \
|
||||||
@@ -74,6 +88,7 @@ find \
|
|||||||
--recipient 0x078A167A8741BD30 \
|
--recipient 0x078A167A8741BD30 \
|
||||||
| aws \
|
| aws \
|
||||||
s3 cp \
|
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