@satharkar Best way is just use something like this:
find $BACKUPDIR -type f -ctime +1 -exec rm -f {} \;
replace $BACKUPDIR with the location of your tar files, and change ctime +1 to for example +30 to delete over 30 days of backups.
In fact I use something like this (some of it depends on the distro I use Debian/Ubuntu hence dpkg command for getting version info this would have to be substituted with yum/rpm on a RHEL based distro):
#!/bin/bash
#
# Script to backup gitlab-ce
# Variables
PKGNAME=gitlab
PKGVER=`dpkg -l | grep -i gitlab | awk '{print $3}'`
GITLABCONFDIR=/etc/gitlab
GITLABBACKUPS=/var/opt/gitlab/backups
BACKUPDIR=/backups/gitlab
BACKUPDATE=`date '+%F'`
# Cleanup old backups and wait a minute
find $BACKUPDIR -type f -ctime +1 -exec rm -f {} \;
sleep 60
# Remove existing gitlab backups
rm -f $GITLABBACKUPS/*
# Backup Gitlab
sudo -u git -H gitlab-rake gitlab:backup:create
tar cvjpf $BACKUPDIR/$PKGNAME-$PKGVER-data-$BACKUPDATE.tar.bz2 $GITLABBACKUPS/*.tar
# Backup Gitlab config
tar cvjpf $BACKUPDIR/$PKGNAME-$PKGVER-config-$BACKUPDATE.tar.bz2 $GITLABCONFDIR
and you will get files backed up with a name of:
-rw-r--r-- 1 root root 637K Jan 26 00:16 gitlab-13.8.0-ce.0-config-2021-01-26.tar.bz2
-rw-r--r-- 1 root root 637K Jan 27 00:16 gitlab-13.8.0-ce.0-config-2021-01-27.tar.bz2
-rw-r--r-- 1 root root 2.9G Jan 26 00:16 gitlab-13.8.0-ce.0-data-2021-01-26.tar.bz2
-rw-r--r-- 1 root root 2.9G Jan 27 00:16 gitlab-13.8.0-ce.0-data-2021-01-27.tar.bz2
-rw-r--r-- 1 root root 657K Jan 28 00:24 gitlab-13.8.1-ce.0-config-2021-01-28.tar.bz2
-rw-r--r-- 1 root root 4.7G Jan 28 00:24 gitlab-13.8.1-ce.0-data-2021-01-28.tar.bz2
and you will have exactly the version of gitlab in the filename for you to know which needs to be installed to restore to.