©XSIBackup-Free: Free Backup Software for ©VMWare ©ESXi

Forum ©XSIBackup: ©VMWare ©ESXi Backup Software


You are not logged in.

#1 2022-03-24 18:43:35

ColtB117
Member
Registered: 2022-03-23
Posts: 8

Retention settings

Hi,

Being new to XSI, I am looking for a way to manage retention. Understanding that pruning is a technically destructive process, is there a way to keep:
1 snap every day if older than 1 day,
1 snap every 7 days if older than 7 days,
1 snap 30 days if older than 30 days,
1 snap every 90 days if older than 90 days,
and no snaps older than 730 days

I know that might not of been the clearest. sad

Thanks,
-Colt

Offline

#2 2022-03-24 20:27:47

admin
Administrator
Registered: 2017-04-21
Posts: 1,962

Re: Retention settings

We got it. The short answer is no sad
The rotation mechanism allows you to keep a number or days of restore points, yet it can't maintain such complex scheme.
You can on the other side script it on your own and run the script at the end of every backup.

Offline

#3 2022-03-24 20:30:51

ColtB117
Member
Registered: 2022-03-23
Posts: 8

Re: Retention settings

admin wrote:

You can on the other side script it on your own and run the script at the end of every backup.

That's what I suspected. I'll share what I come up with here once done.

Thanks,
-Colt

Offline

#4 2022-03-25 11:57:48

admin
Administrator
Registered: 2017-04-21
Posts: 1,962

Re: Retention settings

Remember to use xsibackup --prune /path/to/repository/20220325002123 to remove restore points inside a repository. You can on the other side remove replicas by just removing the folder. Some people like to rotate small groups of replicas when the total size of their VM set is not very big. If you add --replica=cbt, the update of each replica will be almost instant from the second run in each replica point.

Offline

#5 2022-03-25 15:49:20

ColtB117
Member
Registered: 2022-03-23
Posts: 8

Re: Retention settings

admin wrote:

If you add --replica=cbt, the update of each replica will be almost instant from the second run in each replica point.

DC lists 'Full CBT Support' but the feature comparison doesn't list any CBT capability in the other offerings. Am I correct to assume that pro (and lesser licenses) wont have any CBT available?

Offline

#6 2022-03-26 11:31:07

admin
Administrator
Registered: 2017-04-21
Posts: 1,962

Re: Retention settings

CBT support is exclusive to DC version, still regular differential replica will be almost as fast for VMs under 50 GB.

Offline

#7 2022-03-27 03:54:04

ColtB117
Member
Registered: 2022-03-23
Posts: 8

Re: Retention settings

ColtB117 wrote:

I'll share what I come up with here once done.

This is what I came up with. It's pretty simple but does the job for me.

Dailies - After 2 days, it will only retain the most recent backup per day.
Weeklies - After 7 days, it will only retain the most recent backup per 7 days.
Monthlies - After 30 days, it will only retain the most recent backup per 30.
Quarterlies - After 90 days, it will only retain the most recent backup per 90 days.
2 Years - After 730 days, it will not retain any backups older than 730 days.

I plan to run this on my storage, not ESXi. I expect with a bit of rework it could be made to work on ESXi.

Needless to say I take no responsibility for this. I make no guarantee that it's fit for any purpose. If it eats your data you're on your own. Test it in a manner where you can afford for it to fail before using it where you cant. smile

#!/bin/bash

bkuploc='/path/to/backups'
xsibackupexec='/opath/to/xsibackup'

declare backups=()
declare bkup_dates=()
unset lastcheckday
unset lastcheckweek
unset lastcheckmonth
unset lastcheckquarter

now_long=`date -u '+%F %T'`
now_gen=`date -u -d "$now_long" '+%Y/%m/%d 23:59:59 UTC'`
now2day=`date -u -d "$now_gen-2 day" +%s`
now7day=`date -u -d "$now_gen-7 day" +%s`
now30day=`date -u -d "$now_gen-30 day" +%s`
now90day=`date -u -d "$now_gen-90 day" +%s`
now2year=`date -u -d "$now_gen-730 day" +%s`

for i in $(find $bkuploc -maxdepth 1 -type d -regextype posix-egrep -regex "^/.*[0-9]{14}$" -printf '%f\n'); do
	backups+=("${i:0:4}${i:4:2}${i:6:2}${i:8:2}${i:10:2}${i:12:2}")
done

readarray -td '' bkup_dates < <(printf '%s\0' "${backups[@]}" | sort -rz)

for j in "${bkup_dates[@]}"
do
	a=$(date -u -d "${j:0:4}/${j:4:2}/${j:6:2} ${j:8:2}:${j:10:2}:${j:12:2} UTC" +%s)
	if [ "$a" -ge "$now7day" ] && [ "$a" -lt "$now2day" ]; then
		if [ -z ${lastcheckday+x} ]; then
			lastcheckday="$a"
			b=`date -u -d "$(date -u -d @$lastcheckday +%Y%m%d)" +%s`
			echo "Keep, daily, $bkuploc/$j"
		elif [ "$a" -lt "$b" ]; then
			lastcheckday="$a"
			b=`date -u -d "$(date -u -d @$lastcheckday +%Y%m%d)" +%s`
			echo "Keep, daily, $bkuploc/$j"
		else
			echo "Prune, $bkuploc/$j"
			$xsibackupexec --prune "$bkuploc/$j"
		fi
	elif [ "$a" -ge "$now30day" ] && [ "$a" -lt "$now7day" ]; then
		if [ -z ${lastcheckweek+x} ]; then
			lastcheckweek="$a"
			b=`date -u -d "$(date -u -d @$lastcheckweek '+%Y/%m/%d 23:59:59 UTC') - 7 day" +%s`
			echo "Keep, weekly, $bkuploc/$j"
		elif [ "$a" -le "$b" ]; then
			lastcheckweek="$a"
			b=`date -u -d "$(date -u -d @$lastcheckweek '+%Y/%m/%d 23:59:59 UTC') - 7 day" +%s`
			echo "Keep, weekly, $bkuploc/$j"
		else
			echo "Prune, $bkuploc/$j"
			$xsibackupexec --prune "$bkuploc/$j"
		fi
	elif [ "$a" -ge "$now90day" ] && [ "$a" -lt "$now30day" ]; then
		if [ -z ${lastcheckmonth+x} ]; then
			lastcheckmonth="$a"
			b=`date -u -d "$(date -u -d @$lastcheckmonth '+%Y/%m/%d 23:59:59 UTC') - 30 day" +%s`
			echo "Keep, monthly, $bkuploc/$j"
		elif [ "$a" -le "$b" ]; then
			lastcheckmonth="$a"
			b=`date -u -d "$(date -u -d @$lastcheckmonth '+%Y/%m/%d 23:59:59 UTC') - 30 day" +%s`
			echo "Keep, monthly, $bkuploc/$j"
		else
			echo "Prune, $bkuploc/$j"
			$xsibackupexec --prune "$bkuploc/$j"
		fi
	elif [ "$a" -ge "$now2year" ] && [ "$a" -lt "$now90day" ]; then
		if [ -z ${lastcheckquarter+x} ]; then
			lastcheckquarter="$a"
			b=`date -u -d "$(date -u -d @$lastcheckquarter '+%Y/%m/%d 23:59:59 UTC') - 90 day" +%s`
			echo "Keep, monthly, $bkuploc/$j"
		elif [ "$a" -le "$b" ]; then
			lastcheckquarter="$a"
			b=`date -u -d "$(date -u -d @$lastcheckquarter '+%Y/%m/%d 23:59:59 UTC') - 90 day" +%s`
			echo "Keep, quarterly, $bkuploc/$j"
		else
			echo "Prune, $bkuploc/$j"
			$xsibackupexec --prune "$bkuploc/$j"
		fi
	elif [ "$a" -lt "$now2year" ]; then
		echo "Prune, Older than 2 years $bkuploc/$j"
		$xsibackupexec --prune "$bkuploc/$j"
	fi
done

Offline

#8 2022-03-28 08:25:44

admin
Administrator
Registered: 2017-04-21
Posts: 1,962

Re: Retention settings

Thank you, your code snippet will for sure be useful to others. Just reminding you all, use with caution and test thoroughly.

Offline

Board footer