Add monthly huge backups

This commit is contained in:
Salt 2020-07-11 08:59:19 -05:00
parent 4b81bc74c6
commit 9861f54c0f

View File

@ -36,8 +36,29 @@ fi
# WE MAKE BACKUP NOW SERGEI
for dir in /home/*; do
username="$(basename -- "$dir")"
forcefile="$dir/.backup/forcemontly"
[ -d "$dir/.backup" ] || continue
for file in "$dir/.backup/"*; do [ -e "$file" ] || continue; done
tar czhf "$OUTDIR/desktop-$username-{{ inventory_hostname }}-$(date -Iseconds).tar.gz" "$dir/.backup/"*
if (( "$(date +%d)" == "1" )) || [ -f "$forcefile" ]; then
if command -v aws > /dev/null 2>&1 && aws s3 ls "s3://$s3bucket " > /dev/null 2>&1; then
# Time for huge backups piped straight to S3
tar \
--exclude "$dir/.ansible" \
--exclude "$dir/.backup" \
--exclude "$dir/.cache" \
--exclude "$dir/.steam" \
--exclude "$dir/Downloads" \
--exclude "$dir/Dropbox" \
--exclude "$dir/Nextcloud" \
--exclude "$dir/snap" \
czf - "$dir/"* \
| gzip -c | aws s3 cp - "s3://$s3bucket" \
--recursive \
--only-show-errors \
--store-class STANDARD
fi
[ -f "$forcefile" ] && rm "$forcefile"
fi
done