integration clean snapshot
This commit is contained in:
parent
73d68a2a9f
commit
8a03dec28a
45
upsnapz.sh
45
upsnapz.sh
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Time-stamp: <2025-02-10 07:05:07 nomad>
|
# Time-stamp: <2025-02-10 07:14:16 nomad>
|
||||||
|
|
||||||
# Michel Le Cocq <lecocq@ipgp.fr>
|
# Michel Le Cocq <lecocq@ipgp.fr>
|
||||||
# <nomad@neuronfarm.net>
|
# <nomad@neuronfarm.net>
|
||||||
@ -30,6 +30,47 @@
|
|||||||
#
|
#
|
||||||
# regarder si un nouveau kernel existe et si oui faire ce qu'il y a a faire
|
# regarder si un nouveau kernel existe et si oui faire ce qu'il y a a faire
|
||||||
|
|
||||||
|
function cleansnap
|
||||||
|
{
|
||||||
|
printf '\nClean snapshot.\n'
|
||||||
|
|
||||||
|
printf 'Current available bootfs:\n'
|
||||||
|
zfs list -o name,used,usedbysnapshots -r zroot/ROOT -s creation | grep -v '^zroot/ROOT .*'
|
||||||
|
oldest=$(zfs list -H -o name -r zroot/ROOT -s creation | grep -v '^zroot/ROOT$' | head -n 1)
|
||||||
|
oldestdate=$(echo $oldest | cut -d "_" -f 3- | tr '_' '-')
|
||||||
|
current=$(zpool get -H bootfs zroot -o value)
|
||||||
|
printf '\ncurrent bootfs: %s\n' $current
|
||||||
|
printf 'oldest bootfs: %s\n' $oldest
|
||||||
|
printf '\nzroot/ROOT status : \n'
|
||||||
|
zfs list -o used,available,quota,usedbychildren zroot/ROOT
|
||||||
|
|
||||||
|
printf '\nsnapshot to clean older than %s:\n' $oldestdate
|
||||||
|
zfs list -H -o name -t snapshot -s creation -r $current | grep $oldestdate -B10000 | grep -v $oldestdate
|
||||||
|
|
||||||
|
if [ $? -ne 1 ]
|
||||||
|
then
|
||||||
|
printf '\nDo snapshots cleanup ? : %s [Y-n]' $sugsname
|
||||||
|
read docleanup
|
||||||
|
if [ -z $dopromote ]
|
||||||
|
then
|
||||||
|
dopromote='y'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$dopromote" == "y" ]]
|
||||||
|
then
|
||||||
|
for z in $(zfs list -H -o name -t snapshot -s creation -r $current | grep $oldestdate -B10000 | grep -v $oldestdate)
|
||||||
|
do
|
||||||
|
printf 'zfs destroy %s\n' $z
|
||||||
|
sudo zfs destroy $z
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
usedbysnapshots=$(zfs list -H -o usedbysnapshots $current)
|
||||||
|
printf '\nused by snapshot : %s\n' $usedbysnapshots
|
||||||
|
else
|
||||||
|
printf '\tno snapshot older than %s\n' $oldestdate
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function check_zpool_status
|
function check_zpool_status
|
||||||
{
|
{
|
||||||
# check zpool status if it's upgradable
|
# check zpool status if it's upgradable
|
||||||
@ -293,6 +334,6 @@ check_zpool_status
|
|||||||
check_ZFS_BOOT_MENU
|
check_ZFS_BOOT_MENU
|
||||||
echo
|
echo
|
||||||
zpool status
|
zpool status
|
||||||
|
cleansnap
|
||||||
printf '\nNothing else to do.\n'
|
printf '\nNothing else to do.\n'
|
||||||
|
|
||||||
#~/bin/clean-snapshot.sh
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user