<commit_before>#!/usr/bin/env bash

# utility function for exiting
function die {
	echo "$@" >&2
	exit 1
}

SOURCE_DIR="/public"
BACKUPS_DIR="/mnt/lifebackup/loop/backups"
[[ -d "$BACKUPS_DIR" ]] || die "$0: backups dir not found"

MOST_RECENT_BACKUP=$(ls -1 "$BACKUPS_DIR" |grep -E '^[0-9]+$' |sort -n |tail -n 1)
if [[ -n "$MOST_RECENT_BACKUP" ]]; then
	MOST_RECENT_BACKUP_DIR="$BACKUPS_DIR/$MOST_RECENT_BACKUP"
	BACKUP_DIR="$BACKUPS_DIR/$((MOST_RECENT_BACKUP + 1))"
else
	# first backup!
	BACKUP_DIR="$BACKUPS_DIR/1"
fi
rm -fR "$BACKUP_DIR.partial"
mkdir "$BACKUP_DIR.partial"
rsync -avz --delete ${MOST_RECENT_BACKUP_DIR:+--link-dest="$MOST_RECENT_BACKUP_DIR"} "$SOURCE_DIR" "$BACKUP_DIR.partial"
mv "$BACKUP_DIR.partial" "$BACKUP_DIR"<commit_msg>Backup script now logs output<commit_after>#!/usr/bin/env bash

# utility function for exiting
function die {
	echo "$@" >&2
	exit 1
}

SOURCE_DIR="/public"
BACKUPS_DIR="/mnt/lifebackup/loop/backups"
[[ -d "$BACKUPS_DIR" ]] || die "$0: backups dir not found"

MOST_RECENT_BACKUP=$(ls -1 "$BACKUPS_DIR" |grep -E '^[0-9]+$' |sort -n |tail -n 1)
if [[ -n "$MOST_RECENT_BACKUP" ]]; then
	MOST_RECENT_BACKUP_DIR="$BACKUPS_DIR/$MOST_RECENT_BACKUP"
	BACKUP_DIR="$BACKUPS_DIR/$((MOST_RECENT_BACKUP + 1))"
else
	# first backup!
	BACKUP_DIR="$BACKUPS_DIR/1"
fi
PARTIAL_DIR="$BACKUP_DIR.partial"
rm -fR "$PARTIAL_DIR"
mkdir "$PARTIAL_DIR"
rsync >>"$PARTIAL_DIR/backup.log" 2>&1 -avz --delete ${MOST_RECENT_BACKUP_DIR:+--link-dest="$MOST_RECENT_BACKUP_DIR/files"} "$SOURCE_DIR" "$PARTIAL_DIR/files"
mv "$PARTIAL_DIR" "$BACKUP_DIR"
{'fraction_non_alphanumeric': 0.17973231357552583, 'fraction_numerical': 0.012746972594008922, 'mean_word_length': 6.040358744394619, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '37850', 'n_tokens_mistral': 696, 'n_tokens_neox': 669, 'n_words': 124}