#!/bin/bash
#
# sys-snapshots-clean
#
# Clean old snapshosts
#
# (c)2018-2019 Marek Uher <marek@uher.info>
#

SNAPPER_CONFIG=""

for SNAPPER_CONFIG in `snapper list-configs | egrep -v "(^Config|^-)" | awk '{ print $1 }'`; do
	for SNAPPER_SNAPSHOT in `snapper -c ${SNAPPER_CONFIG} list | grep timeline | awk '{ print $1 }'`; do
		echo -en "snapper -c ${SNAPPER_CONFIG} delete ${SNAPPER_SNAPSHOT}: [error code = "
		snapper -c ${SNAPPER_CONFIG} delete ${SNAPPER_SNAPSHOT}
		echo -en $?
		echo "]"
	done
done
for SNAPPER_CONFIG in `snapper list-configs | egrep -v "(^Config|^-)" | awk '{ print $1 }'`; do
	for SNAPSHOT in `snapper -c ${SNAPPER_CONFIG} list | grep "Regular system backup" | awk '{ print $1 }'`; do
		echo -en "snapper -c ${SNAPPER_CONFIG} delete ${SNAPSHOT}: [error code = "
		snapper -c ${SNAPPER_CONFIG} delete ${SNAPSHOT}
	echo -en $?
	echo "]"
	done
done
for SNAPPER_CONFIG in `snapper list-configs | egrep -v "(^Config|^-)" | awk '{ print $1 }'`; do
	for SNAPSHOT in `snapper -c ${SNAPPER_CONFIG} list | grep "apt" | awk '{ print $1 }'`; do
		echo -en "snapper -c ${SNAPPER_CONFIG} delete ${SNAPSHOT}: [error code = "
		snapper -c ${SNAPPER_CONFIG} delete ${SNAPSHOT}
	echo -en $?
	echo "]"
	done
done

exit 0

# /* End of file: sys-snapshots-clean */
