Snapshot naming + Filename

Would it be possible to have the snapshot name I choose in some capacity reflect on the actual filename of the snapshot instead of:
70344a3d.tar
Sometimes I need to find something in an old snapshot (backed up to NAS) and the name would make it much simpler.
I know there will be an issue with some characters and white spaces but perhaps that could be resolved somehow.

Came here looking for the same solution. Backup file names should be meaningful, at least with respect to the date made.

Anyway, I wrote a quick script tonight that may help someone else. On my personal server, I’ve done the manual install and haven’t setup the “hass” binary yet, so this script might not be as useful to someone who can specify the backup name via CLI. Nevertheless, here it is:

#!/bin/bash


#
get_file_create_datetime()
{
	# stat -c %w "$1" --format="%Y"
	date -r "$1" +'%Y-%m-%d_%I-%M%P'
}
make_file_backup_name()
{
	local FILENAME=$(get_file_create_datetime "$1")" - Home Assistant Backup.tar"
	echo "$FILENAME"
}
rename_backup()
{
	local DIR=$(dirname "$1")
	local FILENAME=$(make_file_backup_name "$1")
	local FILEPATH="$DIR/$FILENAME"

	if [ "$1" != "$FILEPATH" ] ; then
		mv "$1" "$FILEPATH"
	fi
}
rename_all_backups()
{
	for FILE_PATH in "$1"/*
	do
		rename_backup "$FILE_PATH"
	done
}

rename_all_backups "$HOME/.homeassistant/backups"

Run the script and it will rename all backup files according to their creation date. Of course, you may want to adjust the hard-coded path, date format, or other parts. Feel free to tweak and upgrade.

i dont think it solves original issue that was reported ;/

I have upvoted this. Seems unfortunate that the name attribute is currently being ignored.

strange longstanding bug? For now I can use the creation date on my share to find the most recent version, but using a name and/or date/time as filename would be an improvement over random.tar

1 Like