Minor reworks to how script is structured for better efficiency
This commit is contained in:
parent
f3520c10ae
commit
c9984c448c
@ -2,5 +2,4 @@
|
|||||||
exec nice -n 10 restic \
|
exec nice -n 10 restic \
|
||||||
-r "s3:{{ backup_s3_aws_endpoint_url }}/{{ backup_s3_bucket }}/restic" \
|
-r "s3:{{ backup_s3_aws_endpoint_url }}/{{ backup_s3_bucket }}/restic" \
|
||||||
-p /opt/restic-password \
|
-p /opt/restic-password \
|
||||||
--verbose \
|
|
||||||
"$@"
|
"$@"
|
||||||
|
@ -48,16 +48,18 @@ fi
|
|||||||
# Helper functions
|
# Helper functions
|
||||||
backup() {
|
backup() {
|
||||||
# Takes a file or directory to backup and backs it up
|
# Takes a file or directory to backup and backs it up
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$@" ] && return 1
|
||||||
|
|
||||||
dir="$1"
|
|
||||||
echo "- $dir"
|
|
||||||
|
|
||||||
if command -v restic > /dev/null 2>&1; then
|
if command -v restic > /dev/null 2>&1; then
|
||||||
|
for dir in "$@"; do
|
||||||
|
echo "- $dir"
|
||||||
|
done
|
||||||
/opt/restic-wrapper \
|
/opt/restic-wrapper \
|
||||||
backup \
|
backup \
|
||||||
"$dir"
|
"$@"
|
||||||
else
|
else
|
||||||
|
dir="$@"
|
||||||
|
echo "- $dir"
|
||||||
nice -n 10 tar {{ backup_s3backup_tar_args }}{{ backup_s3backup_tar_args_extra }} \
|
nice -n 10 tar {{ backup_s3backup_tar_args }}{{ backup_s3backup_tar_args_extra }} \
|
||||||
{% for item in backup_s3backup_exclude_list + backup_s3backup_exclude_list_extra %}
|
{% for item in backup_s3backup_exclude_list + backup_s3backup_exclude_list_extra %}
|
||||||
--exclude "{{ item }}" \
|
--exclude "{{ item }}" \
|
||||||
@ -88,15 +90,19 @@ if [ -n "${DIRS[*]}" ]; then
|
|||||||
echo "- {{ item }}"
|
echo "- {{ item }}"
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
echo "Will upload resultant backups to {{ backup_s3_bucket }}"
|
echo "Will upload resultant backups to {{ backup_s3_bucket }}"
|
||||||
for dir in "${DIRS[@]}"; do
|
if command -v restic > /dev/null 2>&1; then
|
||||||
if [ "$dir" == "/data" ]; then
|
backup ${DIRS[*]}
|
||||||
for datadir in "$dir"/*; do
|
else
|
||||||
[ -e "$datadir" ] && backup "$datadir"
|
for dir in "${DIRS[@]}"; do
|
||||||
done
|
if [ "$dir" == "/data" ]; then
|
||||||
else
|
for datadir in "$dir"/*; do
|
||||||
backup "$dir"
|
[ -e "$datadir" ] && backup "$datadir"
|
||||||
fi
|
done
|
||||||
done
|
else
|
||||||
|
backup "$dir"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Dump Postgres DBs, if possible
|
# Dump Postgres DBs, if possible
|
||||||
|
Loading…
x
Reference in New Issue
Block a user