Priority by disk usage

cPanel, Industry leading hosting platform with world-class support.
Post Reply
Mauzer
Posts: 3
Joined: November 23rd, 2022, 3:44 am

Priority by disk usage

Post by Mauzer »

I have about 300 clients on a server and working out a Disaster Recovery Plan.

What I want to do is to prioritize smaller accounts (backup and restore). Why? Because if we restore the smaller accounts first it will get more clients back online quicker.

Ideally, I would like something like this:

Using:
0-5GB -> High Priority
5-10GB -> Normal Priority
10GB> -> Low Priority

The script example at https://blog.jetapps.com/improve-perfor ... ty-system/ only works with inodes, not disk usage.

If I change lowinode=3500 to lowusage=5000 and normusage=10000

AND

findsize=$(jetbackup5api -F getAccount -D _id=${id} | grep 'disk_usage:' | awk '{print $2}')

This does not seem to be doing what I need.

Anyone else had a similar issue before?
Mauzer
Posts: 3
Joined: November 23rd, 2022, 3:44 am

Re: Priority by disk usage

Post by Mauzer »

Or even better would actually be to restore the accounts from small to large usage. In other words, the smallest disk usage account is restored first and then progress as they accounts get larger in size. So the account with the most disk usage will be restored last.
JetAppsAdam
Staff Member
Staff Member
Posts: 74
Joined: August 5th, 2022, 11:01 pm

Re: Priority by disk usage

Post by JetAppsAdam »

Hello Mauzer,

Looking at the changes that you have made, the likely reason that you are not achieving the desired result is that the JetBackup 5 API calculates disk usage in bytes. This means that to give accounts under 5GB a high priority, you would have to set the lowusage variable to 5000000000. I have gone ahead and modified the example script to fit the needs that you have described.

Code: Select all

#!/bin/bash

accountids=($(jetbackup5api -F listAccounts | grep -w '_id' | awk '{print $2}'))


#logic for finding queue priority id to be used for assignment
queuepriohigh=($(jetbackup5api -F listQueuePriorities | grep -w 'name: High' -B1 | grep -w '_id:' | awk '{print $2}'))
queueprionorm=($(jetbackup5api -F listQueuePriorities | grep -w 'name: Normal' -B1 | grep -w '_id:' | awk '{print $2}'))
queuepriolow=($(jetbackup5api -F listQueuePriorities | grep -w 'name: Low' -B1 | grep -w '_id:' | awk '{print $2}'))


#inode limit variables. Can be changed to suit individual server needs.
lowusage=5000000000 #accounts below this limit will be assigned to "low" priority
normusage=10000000000 #accounts between low and normal limit will be assigned to "normal". Above normal limit will be assigned to "high"

for id in ${accountids[@]}
do
    checktag=$(jetbackup5api -F getAccount -D _id=${id} | grep 'queue_priority:' | awk '{print $2}') #logic for checking if already tagged

        if [ -z "$checktag" ] #if no tag exists assign tag based on inode usage.
            then
                findsize=$(jetbackup5api -F getAccount -D _id=${id} | grep 'disk_usage:' | awk '{print $2}')

                    if [[ $findsize -gt 0 ]] && [[ $findsize -le $lowusage ]];
                        then
                            jetbackup5api -F  manageAccount -D "_id=${id}&queue_priority=${queuepriolow}"
                            echo "Tagging id: ${id} under 5GB Disk Usage"
                    elif [[ $findsize -gt $lowusage ]] && [[ $findsize -le $normusage ]];
                        then
                            jetbackup5api -F  manageAccount -D "_id=${id}&queue_priority=${queueprionorm}"
                            echo "Tagging id: ${id} between 5GB and 10GB Disk Usage"
                    elif [[ $findsize -gt $normusage ]];
                        then
                            jetbackup5api -F  manageAccount -D "_id=${id}&queue_priority=${queuepriohigh}"
                            echo "Tagging id: ${id} above 10GB Disk Usage"
            fi
        else
        echo "${id} already proritized. Skipping..."
fi
done
echo "Done."
Thank you,

Adam G
JetApps, LLC.
JetApps.com | JetBackup.com
Post Reply