Skip to main content

How to limit the number of backups users can store locally?

Comments

21 comments

  • andrew.n
    If I'm not mistaken though I'm not 100% sure the local backups counts against the accounts's storage limit so basically the available space is the limiting factor here. Please @cPanelLauren confirm me.
    0
  • Shoss
    Hi @andrew.n Thank you for replying. I am not referring to the storage. I am referring to the number of backup files. For example, a user won't be able to store more than 5 backup files under their account. If they go to create another backup, they will be presented a warning to tell them that backup limit reached and they need to delete at least one file. Or, the cPanel will just delete the oldest backup and store the new backup under their account, maintaining the total count of 5 backup files.
    0
  • andrew.n
    As far as I know there is no option to limit this at the moment.
    0
  • Shoss
    @andrew.n Thank you for replying. Perhaps a custom hook/script that checks the number of backup files before creating any backup would be a solution?
    0
  • andrew.n
    Yes that could be a solution. You can find more information about hooks at Guide to Standardized Hooks - Developer Documentation - cPanel Documentation
    0
  • cPAdminsMichael
    Hi, You would be able to do that with fx JetBackup's snapshots. You cannot define the limit per account - but you could group accounts if you want to have a differentiated setup :)
    0
  • cPanelLauren
    The backups, if they are owned by the user will count against the user's storage. There isn't anything native to cPanel that limits backups to a certain number, you'd want to use JetBackup as suggested or create a custom script. A lot of shared hosting providers allow backups to remain on the account for a certain amount of days. So for example. No backups would be present if older than 7 days.
    0
  • Shoss
    A lot of shared hosting providers allow backups to remain on the account for a certain amount of days. So for example. No backups would be present if older than 7 days.

    Thank you for replying. This could be an alternative solution. Would you direct me on how I can do that? I use JetBackup only and the native backup tool is disabled. I wanted a way so that users cannot store more than X number of backup files. This would allow a way for the users to keep a backup under their account.
    0
  • Shoss
    ou would be able to do that with fx JetBackup's snapshots. You cannot define the limit per account - but you could group accounts if you want to have a differentiated setup

    Thank you for replying. I use JetBackup incremental backup. I want to provide a way for the users to store their account backups under their account, while also limiting them on how many backups they can store.
    0
  • cPAdminsMichael
    Thank you for replying. I use JetBackup incremental backup. I want to provide a way for the users to store their account backups under their account, while also limiting them on how many backups they can store.

    I don't think you can configure JetBackup to store the automated/nightly backups under the accounts' own volume, if that's what you ask. You can, however, configure Snapshots in JetBackup and set limits, and the users would then be able to do ad-hoc backups (snapshots) of their accounts and also restore from those.
    0
  • Shoss
    @Michael Svendsen Thank you for replying. I am not after that feature. What I need is a way to limit the number of cPanel backups a user can store on their account.
    0
  • cPAdminsMichael
    @Michael Svendsen Thank you for replying. I am not after that feature. What I need is a way to limit the number of cPanel backups a user can store on their account.

    Ok, then I'm not 100% sure what you mean and what you want to achive :) If you are talking about retention policy, both cPanel Backup and JetBackup can be configured to retain only the last x backups. In JetBackup that's done as a schedule:
    0
  • Shoss
    @Michael Svendsen Thank you for replying. What you referred to is the WHM's Automated Backup Tool (apart from JetBackup). I am referring to the backup tool inside user's cPanel. Though the names are the same, these two tools are much different. WHM's backup tool is used to create and store automated backups. I don't use that, so it remains disabled. The backup tool inside cPanel is used to manually generate full and partial backups. I want to limit the number of these user-generated backup files that a user can store on their hosting account.
    0
  • cPAdminsMichael
    Ahhhhh :) I don't think you are able to limit the amount of those stored backups, as they will just count towards the users quota anyway. HOWEVER.... as you wrote that you are using JetBackup - why don't you just use their snapshot feature? It can do the same - and with your limitation wishes ;)
    0
  • cPanelLauren
    You can limit the stored backups but you would need to write a custom script. The script would be fairly simple, but would be easiest to do for a specific time frame. For example: find /home/ -name '*.tar.gz' -type f -mtime +7 -exec rm {}
    0
  • Mathan kb
    Thank you for replying. This could be an alternative solution. Would you direct me on how I can do that? I use JetBackup only and the native backup tool is disabled. I wanted a way so that users cannot store more than X number of backup files. This would allow a way for the users to keep a backup under their account.

    Thanks it was helpful
    0
  • Shoss
    @cPanelLauren Thank you for the hint. Where do I store the script, and what do I name it? The script should also have a way to output a message and a variable for cPanel to know whether it should proceed with the backup, or not. For example, if the script outputs 0, cPanel will proceed with creating a backup. If it outputs 1, cPanel will abort the backup and display a message defined in the script, such as "backup limit exceeded. You can only store five backups. Please delete some backups before creating one." Or, as in your sample script, it might just delete the oldest backup and proceed with creating a new one. However, if the above can be done, it would be great. Does cPanel have a native way of executing a specific script right before performing the backup? For example, cPanel might search for a "backup_pre" script in a specific directory, and if the script exists, cPanel would execute it. Does cPanel have any such feature?
    0
  • Shoss
    @Michael Svendsen cPanel backups and JetBackup backups aren't the same. Only a few cPanel based providers provide JetBackup. I am not interested in JetBackup for this feature. If there is a third party tool that can limit cPanel backups, that would be awesome, too. Besides, a cPanel backup can be used to automatically restore the account on any cPanel based server. It is mobile.
    0
  • cPanelLauren
    So what I provided is able to be added as a cron job, but you could potentially also write a script that will perform the actions you're suggesting as well. The Guide to Standardized hooks which @andrew.n provided might be helpful in setting this up to complete after a backup job is finished.
    0
  • Shoss
    @cPanelLauren Thank you for replying. It seems there is a PkgAcct Create event which might be the one I am looking for. This would be my very first scripting with cPanel. I will keep you updated once completed the script.
    0
  • andrew.n
    Good luck! :)
    0

Please sign in to leave a comment.